• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

cms/modules/qaos.lib.php

Go to the documentation of this file.
00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 { 
00004         header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005         echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006         echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007         exit(1);
00008 }
00041 class qaos implements module {
00042         private $userId;
00043         private $moduleComponentId;
00044         private $action;
00045         public function getHtml($gotuid, $gotmoduleComponentId, $gotaction) {
00046                 $this->userId = $gotuid;
00047                 $this->moduleComponentId = $gotmoduleComponentId;
00048                 $this->action = $gotaction;
00049                 if ($this->action == "view")
00050                         return $this->actionView();
00051                 if ($this->action == "edit")
00052                         return $this->actionEdit($this->moduleComponentId);
00053                 if ($this->action == "create")
00054                         return $this->createModule($this->moduleComponentId);
00055                 if ($this->action == "delete")
00056                         return $this->deleteModule($this->moduleComponentId);
00057                 if ($this->action == "copy")
00058                         return $this->copyModule($this->moduleComponentId);
00059                 if ($this->action == "score")
00060                         return $this->actionScore($this->moduleComponentId);
00061                 if ($this->action == "qaosadmin")
00062                         return $this->actionQaosadmin();
00063         }
00064         public function actionView(){
00065                 $score = false;
00066                 return $this->generateTree($this->moduleComponentId,$score);
00067         }
00068         public function actionQaosadmin(){
00069                 $moduleComponentId = $this->moduleComponentId;
00070                 $score = true;
00071                 if($_GET['subaction']=='viewscore'){
00072                         if(isset($_GET['useremail'])){
00073                                 $userId = getUserIdFromEmail($_GET['useremail']);
00074                                 $htmlOut = "<br /><br />People who has been rated by this person:<br /><br />";
00075                                 $query = "SELECT * FROM `qaos_scoring` WHERE user_id = $userId";
00076                                 $result = mysql_query($query);
00077                                 $htmlOut .= "<table border=\"1\">";
00078                                 $htmlOut .= "<tr><th>Target User Full Name</th><th>Target User Team</th><th>Target User Designation</th><th>Target User Score1</th><th>Target User Reason1</th><th>Target User Score2</th><th>Target User Reason2</th><th>Target User Score3</th><th>Target User Reason3</th><th>Target User Score4</th><th>Target User Reason4</th><th>Target User Score5</th><th>Target User Reason5</th>";
00079                                 while($row = mysql_fetch_assoc($result)){
00080                                         $targetUserId = $row['targetuser_id'];
00081                                         $targetUserFullName = getUserFullName($targetUserId);
00082                                         $targetUserTeam = $this->getTeamNameFromTeamId($this->getTeamId($targetUserId));
00083                                         $targetUserDesignation = $this->getDesignationNameFromDesignationId($this->getDesignationId($targetUserId));
00084                                         $score1 = $row['qaos_score1'];$score2 = $row['qaos_score2'];$score3 = $row['qaos_score3'];$score4 = $row['qaos_score4'];$score5 = $row['qaos_score5'];
00085                                         $reason1 = $row['qaos_reason1'];$reason2 = $row['qaos_reason2'];$reason3 = $row['qaos_reason3'];$reason4 = $row['qaos_reason4'];$reason5 = $row['qaos_reason5'];
00086                                         $htmlOut .=<<<USERDATA
00087                                                                 <tr>
00088                                                                         <td> $targetUserFullName </td>
00089                                                                         <td> $targetUserTeam </td>
00090                                                                         <td> $targetUserDesignation </td>
00091                                                                         <td> $score1 </td>
00092                                                                         <td> $reason1 </td>
00093                                                                         <td> $score2 </td>
00094                                                                         <td> $reason2 </td>
00095                                                                         <td> $score3 </td>
00096                                                                         <td> $reason3 </td>
00097                                                                         <td> $score4 </td>
00098                                                                         <td> $reason4 </td>
00099                                                                         <td> $score5 </td>
00100                                                                         <td> $reason5 </td>
00101                                                                                                 
00102                                                                         
00103                                                                 </tr>
00104                                                                                                 
00105 USERDATA;
00106                                 }
00107                                 $query = "SELECT count(*) as count FROM `qaos_scoring` WHERE user_id = $userId";
00108                                 $result = mysql_query($query);
00109                                 $row = mysql_fetch_assoc($result);
00110                                 $htmlOut .= "</table> <br />Total No of persons this guy has rated : ".$row['count'];
00111                                  
00112                                 $htmlOut .= "<br /><br /><br />People who has rated this person:<br /><br />";
00113                                 $query = "SELECT * FROM `qaos_scoring` WHERE targetuser_id = $userId";
00114                                 $result = mysql_query($query);
00115                                 $htmlOut .= "<table border=\"1\">";
00116                                 $htmlOut .= "<tr><th>User Full Name</th><th>User Team</th><th>User Designation</th><th>User Score1</th><th>User Reason1</th><th>User Score2</th><th>User Reason2</th><th>User Score3</th><th>User Reason3</th><th>User Score4</th><th>User Reason4</th><th>User Score5</th><th>User Reason5</th>";
00117                                 while($row2 = mysql_fetch_assoc($result)){
00118                                         $targetUserId = $row2['targetuser_id'];
00119                                         $targetUserFullName = getUserFullName($userId);
00120                                         $targetUserTeam = $this->getTeamNameFromTeamId($this->getTeamId($userId));
00121                                         $targetUserDesignation = $this->getDesignationNameFromDesignationId($this->getDesignationId($userId));
00122                                         $score1 = $row2['qaos_score1'];$score2 = $row2['qaos_score2'];$score3 = $row2['qaos_score3'];$score4 = $row2['qaos_score4'];$score5 = $row2['qaos_score5'];
00123                                         $reason1 = $row2['qaos_reason1'];$reason2 = $row2['qaos_reason2'];$reason3 = $row2['qaos_reason3'];$reason4 = $row2['qaos_reason4'];$reason5 = $row2['qaos_reason5'];
00124                                         $htmlOut .=<<<USERDATA
00125                                                                 <tr>
00126                                                                         <td> $targetUserFullName </td>
00127                                                                         <td> $targetUserTeam </td>
00128                                                                         <td> $targetUserDesignation </td>
00129                                                                         <td> $score1 </td>
00130                                                                         <td> $reason1 </td>
00131                                                                         <td> $score2 </td>
00132                                                                         <td> $reason2 </td>
00133                                                                         <td> $score3 </td>
00134                                                                         <td> $reason3 </td>
00135                                                                         <td> $score4 </td>
00136                                                                         <td> $reason4 </td>
00137                                                                         <td> $score5 </td>
00138                                                                         <td> $reason5 </td>
00139                                                                 </tr>
00140 USERDATA;
00141                                 }
00142                                 $query = "SELECT count(*) as count FROM `qaos_scoring` WHERE targetuser_id = $userId";
00143                                 $result = mysql_query($query);
00144                                 $row = mysql_fetch_assoc($result);
00145                                 $htmlOut .= "</table><br />Total number of person who have rated this person : ".$row['count']; 
00146                                 
00147                                 return $htmlOut;
00148                         }
00149                         return $this->generateTree($this->moduleComponentId,$score);
00150                 }
00151                 
00152                 $htmlOut .=<<<ADMIN
00153                                         <a href="./+qaosadmin&subaction=addteam">Add Teams</a><br />
00154                                         <a href="./+qaosadmin&subaction=adddesignation">Add Designation</a><br />
00155                                         <a href="./+qaosadmin&subaction=changeteam">Change teams for the user</a><br />
00156                                         <a href="./+qaosadmin&subaction=viewscore">View Scores</a><br />
00157 ADMIN;
00158                 return $htmlOut;
00159         }
00160         public function actionEdit($moduleComponentId){
00161         global $urlRequestRoot;
00162         global $sourceFolder,$cmsFolder;
00163         global $templateFolder;
00164         $scriptsFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts";
00165         $imagesFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images";
00166 
00167                 if(isset($_GET['subaction'])){
00168                         if($_GET['subaction']=='addteam'){
00169                                 if(isset($_POST['btnAddTeam'])){
00170                                         $query = "SELECT MAX(`qaos_team_id`)  AS max FROM `qaos_teams`";
00171                                         $result = mysql_query($query);
00172                                         $resultArray = mysql_fetch_assoc($result);
00173                                         $max = $resultArray['max'];
00174                                         for($i=1; $i<6;$i++){
00175                                                 if($teamName=$_POST["qaos_team".$i.""]){
00176                                                         $query = "SELECT * FROM `qaos_teams` WHERE `qaos_team_name` LIKE '$teamName%'";
00177                                                         $result = mysql_query($query);
00178                                                         if(mysql_num_rows($result)>1){
00179                                                                 displayerror("The $teamName team already exists in the database.");
00180                                                                 continue;
00181                                                         }
00182                                                         $teamId = $max + $i;
00183                                                         $teamDesc = $_POST["team_desc".$i.""];
00184                                                         $query = "INSERT INTO `qaos_teams` (`page_modulecomponentid`,`qaos_team_id`,`qaos_team_name`,`qaos_team_description`) VALUES ('$moduleComponentId','$teamId','$teamName','$teamDesc')";
00185                                                         $result = mysql_query($query);
00186                                                         if(!$result)
00187                                                                 displayerror("The team '$teamName' could not be added. Please try again.");
00188 
00189                                                 }
00190                                         }
00191                                 }
00192                         }
00193 
00194                         elseif($_GET['subaction']=='changeversion'){
00195                                 if(isset($_POST['btnSubmitVersion'])){
00196                                         $query = "UPDATE `qaos_version` SET `qaos_version` = '$_POST[qaos_version]' WHERE `page_modulecomponentid` = $moduleComponentId";
00197                                         $result = mysql_query($query);
00198                                         if(mysql_query($query))
00199                                                 displayinfo("The version has been successfully updated.");
00200                                         else
00201                                                 displayinfo("There was some error while updating the version. Please check your query once.");
00202                                         }
00203                         }
00204                         elseif($_GET['subaction']=='addteammember'){
00205                                 if(isset($_POST['btnAddTeamMember'])){
00206                                         $emailName = $_POST['useremail'];
00207                                         $input = explode(" - ",$emailName);
00208                                         $email = $input[0];
00209                                         $designation = $_POST['userdesignation'];
00210                                         $team = $_POST['userteam'];
00211                                         $parentTeam =$_POST['userparentteam'];
00212                                         $parentDesignation = $_POST['userparentdesignation'];
00213                                         $name = $this->addTeamMember($email,$designation,$team,$parentTeam,$parentDesignation);
00214                                         if($team = "Qaos"){
00215                                                 $this->addQaosTeamMember(getUserIdFromEmail($email),$_POST['qaosteam1'],$_POST['qaosteam2'],$_POST['qaosteam3'],$_POST['qaosteam4']);
00216                                         }
00217                                 }
00218                         }
00219                         elseif($_GET['subaction'] == 'getsuggestions' && isset($_GET['forwhat'])) {
00220                                 echo $this->getSuggestions($_GET['forwhat'], $_GET['suggestiontype']);
00221                                 exit();
00222                         }
00223                 }
00224 
00225 
00226                 $queryVersion = "SELECT `qaos_version` FROM `qaos_version` WHERE `page_modulecomponentid` = $moduleComponentId";
00227                 $resultVersion = mysql_query($queryVersion);
00228                 $row = mysql_fetch_row($resultVersion);
00229                 $version = $row[0];
00230                 $html .= "<h2>$version</h2>     <br />";
00231                 if(getPermissions($this->userId,getPageIdFromModuleComponentId("qaos",$this->moduleComponentId),"create")){
00232                         $html .= <<<EDITQAOS
00233                         <div class="changeqaosversion">
00234                                 <form id="changeqaosversion" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=changeversion">
00235                                         <fieldset style="width:80%">
00236                                                 <legend><b>Change the Version</b></legend>
00237                                                 <table>
00238                                                         <tr>
00239                                                                 <td>
00240                                                                         Changer Qaos version:
00241                                                                 </td>
00242                                                                 <td>
00243                                                                         <input name="qaos_version" id="qaos_version" value="$version" type="text">
00244                                                                 </td>
00245                                                                 <td><input type="submit" name="btnSubmitVersion" id="submitbutton" value="Save Version"></td>
00246                                                         </tr>
00247                                                 </table>
00248                                         </fieldset>
00249                                 </form>
00250                         </div>
00251 EDITQAOS;
00252                 }
00253                 $html .= "<br /><h3>Teams in Pragyan 2008: </h3><br />";
00254                 $queryTeam = "SELECT * FROM `qaos_teams` WHERE `page_modulecomponentid`=$moduleComponentId ORDER BY `qaos_team_name`";
00255                 $resultTeam = mysql_query($queryTeam);
00256                 $html.= "<table border=\"1\"><tr><td><b>Team Name</b></td><td><b>Team Description</b></td><td><b>Team Representative</b></td></tr>";
00257                 while($row = mysql_fetch_row($resultTeam)){
00258                         $team = $row[2];
00259                         $desc = $row[3];
00260                         $repr = $row[4];
00261                         $html .= "<tr><td>$team</td><td>$desc</td><td>$repr</td></tr>";
00262                 }
00263                 $html .= "</table><br /><br />";
00264                 $userTeamId = $this->getTeamId($this->userId);
00265                 if($userTeamId ==1){
00266                 $html .=<<<ADDTEAMS
00267                 <div class="registrationform">
00268                         <div class="addteam">
00269                                 <form id="addteam" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=addteam">
00270                                         <fieldset style="width:80%">
00271                                                 <legend><b>Add Teams</b></legend>
00272                                                 <table>
00273                                                         <tr>
00274                                                                         <tr>
00275                                                                                 <td>
00276                                                                                         Enter the Team Name:
00277                                                                                 </td>
00278                                                                                 <td>
00279                                                                                         <input name="qaos_team1" id="qaos_team" type="text">
00280                                                                                 </td>
00281                                                                         </tr>
00282                                                                         <tr>
00283                                                                                 <td>
00284                                                                                         Enter the Team Description:
00285                                                                                 </td>
00286                                                                                 <td>
00287                                                                                         <input name="team_desc1" id="team_desc" type="text">
00288                                                                                 </td>
00289                                                                         </tr>
00290                                                         </tr>
00291                                                 </table>
00292                                                 <input value="Add more teams" onclick="javascript:toggleuploadfiles(this);" type="button">
00293                                         <span class="hiddenteams"><table>
00294                                                         <tr>
00295                                                                                 <td>
00296                                                                                 Enter the Team Name:
00297                                                                                 </td>
00298                                                                                 <td>
00299                                                                                         <input name="qaos_team2" id="qaos_team" type="text">
00300                                                                                 </td>
00301                                                                         </tr>
00302                                                                         <tr>
00303                                                                                 <td>
00304                                                                                         Enter the Team Description:
00305                                                                                 </td>
00306                                                                                 <td>
00307                                                                                         <input name="team_desc2" id="team_desc" type="text">
00308                                                                                 </td>
00309                                                                         </tr>
00310                                                                         <tr><td><br /></td></tr>
00311 
00312                                                                         <tr>
00313                                                                                 <td>
00314                                                                                         Enter the Team Name:
00315                                                                                 </td>
00316                                                                                 <td>
00317                                                                                         <input name="qaos_team3" id="qaos_team" type="text">
00318                                                                                 </td>
00319                                                                         </tr>
00320                                                                         <tr>
00321                                                                                 <td>
00322                                                                                         Enter the Team Description:
00323                                                                                 </td>
00324                                                                                 <td>
00325                                                                                         <input name="team_desc3" id="team_desc" type="text">
00326                                                                                 </td>
00327                                                                         </tr>
00328                 <tr><td><br /></td></tr>
00329                                                                 <tr>
00330                                                                                 <td>
00331                                                                                         Enter the Team Name:
00332                                                                                 </td>
00333                                                                                 <td>
00334                                                                                         <input name="qaos_team4" id="qaos_team" type="text">
00335                                                                                 </td>
00336                                                                         </tr>
00337                                                                         <tr>
00338                                                                                 <td>
00339                                                                                         Enter the Team Description:
00340                                                                                 </td>
00341                                                                                 <td>
00342                                                                                         <input name="team_desc4" id="team_desc" type="text">
00343                                                                                 </td>
00344                                                                         </tr>
00345                 <tr><td><br /></td></tr>
00346                                                                 <tr>
00347                                                                                 <td>
00348                                                                                         Enter the Team Name:
00349                                                                                 </td>
00350                                                                                 <td>
00351                                                                                         <input name="qaos_team5" id="qaos_team" type="text">
00352                                                                                 </td>
00353                                                                         </tr>
00354                                                                         <tr>
00355                                                                                 <td>
00356                                                                                         Enter the Team Description:
00357                                                                                 </td>
00358                                                                                 <td>
00359                                                                                         <input name="team_desc5" id="team_desc" type="text">
00360                                                                                 </td>
00361                                                                         </tr>
00362 
00363                                                         </table>
00364                                         </span>
00365                                                         <tr>
00366                                                                 <td>
00367                                                                         <input type="submit" name="btnAddTeam" id="submitbutton" value="Submit">
00368                                                                 </td>
00369                                                         </tr>
00370 
00371                                         </fieldset>
00372                                 </form>
00373                         </div>
00374                 </div>
00375                 <style type="text/css">
00376                         .hiddenteams{display:none;}
00377                         .shownteams{display:block;}
00378                 </style>
00379                 <script language="javascript" type="text/javascript">
00380                         function toggleuploadfiles(gett) {
00381                                 if(gett.nextSibling.nextSibling.className != "shownteams")
00382                                 {
00383                                         gett.nextSibling.nextSibling.className = "shownteams";
00384                                         gett = gett.nextSibling.nextSibling;
00385                                 }
00386                                 else
00387                                 {
00388                                         gett.nextSibling.nextSibling.className = "hiddenteams";
00389                                         gett = gett.nextSibling.nextSibling;
00390                                 }
00391                         }
00392                 </script>
00393 ADDTEAMS;
00394                 }
00395                 $html .= "<br />";
00396                 $html .=<<<ADDPERSON
00397                 <script type="text/javascript" language="javascript">
00398                 <!--
00399                         imgAjaxLoading = new Image();
00400                         imgAjaxLoading.src = '$imagesFolder/ajaxloading.gif';
00401                 -->
00402                 </script>
00403                 <style type="text/css">
00404                 <!--
00405                         span.suggestion {
00406                                 padding: 2px 4px 2px 4px;
00407                                 display: block;
00408                                 background-color: white;
00409                                 cursor: pointer;
00410                         }
00411                         span.suggestion:hover {
00412                                 background-color: #DEDEDE;
00413                         }
00414                 -->
00415                 </style>
00416                 <script type="text/javascript" language="javascript" src="$scriptsFolder/ajaxsuggestionbox.js"></script>
00417                 <div class="registrationform">
00418                         <div class="addteammember">
00419 
00420                                 <form id="addteammember" method="POST" onsubmit="return checkProfileForm(this)" action="./+edit&subaction=addteammember">
00421                                         <fieldset style="width:80%">
00422                                                 <legend><b>Add Team Members</b></legend>
00423                                                         <table>
00424                                                                 <tr>
00425                                                                         <td>
00426                                                                                 Enter the Team Member Name:
00427                                                                         </td>
00428                                                                         <td>
00429                                                                                 <input type="text" name="useremail" id="userEmail" autocomplete="off" style="width: 256px" />
00430                                                                                 <div id="suggestionsName" class="suggestionbox"></div>
00431                                                                         </td>
00432                                                                 </tr>
00433                                                                 <tr>
00434                                                                         <td>
00435                                                                                 Enter the User Designation:
00436                                                                         </td>
00437                                                                         <td>
00438                                                                                 <input type="text" name="userdesignation" id="userDesignation" autocomplete="off" style="width: 256px" />
00439                                                                         <div id="suggestionsDesignation" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00440                                                                         </td>
00441                                                                 </tr>
00442                                                                 <tr>
00443                                                                         <td>
00444                                                                                 Enter the Team Name:
00445                                                                         </td>
00446                                                                         <td>
00447                                                                                 <input type="text" name="userteam" id="userTeam" autocomplete="off" style="width: 256px" />
00448                                                                                 <div id="suggestionsTeam" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00449                                                                         </td>
00450                                                                 </tr>
00451                                                                 <tr>
00452                                                                         <td>
00453                                                                                 Enter the Parent Team Name:
00454                                                                         </td>
00455                                                                         <td>
00456                                                                                 <input type="text" name="userparentteam" id="userParentTeam" autocomplete="off" style="width: 256px" />
00457                                                                                 <div id="suggestionsParentTeam" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00458                                                                         </td>
00459                                                                 </tr>
00460                                                                 <tr>
00461                                                                         <td>
00462                                                                                 Enter the Parent Designation:
00463                                                                         </td>
00464                                                                         <td>
00465                                                                                 <input type="text" name="userparentdesignation" id="userParentDesignation" autocomplete="off" style="width: 256px" />
00466                                                                                 <div id="suggestionsParentDesignation" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00467                                                                         </td>
00468                                                                 </tr>
00469                                                                 <tr>
00470                                                                         <td>
00471                                                                                 Enter Qaos Team1:
00472                                                                         </td>
00473                                                                         <td>
00474                                                                                 <input type="text" name="qaosteam1" id="qaosTeam1" autocomplete="off" style="width: 256px" />
00475                                                                                 <div id="suggestionsQaosTeam1" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00476                                                                         </td>
00477                                                                 </tr>
00478                                                                 <tr>
00479                                                                         <td>
00480                                                                                 Enter Qaos Team2:
00481                                                                         </td>
00482                                                                         <td>
00483                                                                                 <input type="text" name="qaosteam2" id="qaosTeam2" autocomplete="off" style="width: 256px" />
00484                                                                                 <div id="suggestionsQaosTeam2" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00485                                                                         </td>
00486                                                                 </tr>
00487                                                                 <tr>
00488                                                                         <td>
00489                                                                                 Enter Qaos Team3:
00490                                                                         </td>
00491                                                                         <td>
00492                                                                                 <input type="text" name="qaosteam3" id="qaosTeam3" autocomplete="off" style="width: 256px" />
00493                                                                                 <div id="suggestionsQaosTeam3" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00494                                                                         </td>
00495                                                                 </tr>
00496                                                                 <tr>
00497                                                                         <td>
00498                                                                                 Enter Qaos Team4:
00499                                                                         </td>
00500                                                                         <td>
00501                                                                                 <input type="text" name="qaosteam4" id="qaosTeam4" autocomplete="off" style="width: 256px" />
00502                                                                                 <div id="suggestionsQaosTeam4" style="background-color: white; width: 260px; border: 1px solid black; position: absolute; overflow-y: scroll; max-height: 180px; display: none"></div>
00503                                                                         </td>
00504                                                                 </tr>
00505                                                                 
00506                                                                 <tr>
00507                                                                         <td><input type="submit" name="btnAddTeamMember" id="submitbutton" value="Add Team Member"></td>
00508                                                                 </tr>
00509 
00510                                                         <script language="javascript" type="text/javascript">
00511                                                         <!--
00512                                                                 nameSuggestionBox = new SuggestionBox(document.getElementById('userEmail'), document.getElementById('suggestionsName'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=username');
00513                                                                 nameSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00514                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userDesignation'), document.getElementById('suggestionsDesignation'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=designation');
00515                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00516                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userTeam'), document.getElementById('suggestionsTeam'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00517                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00518                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userParentTeam'), document.getElementById('suggestionsParentTeam'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00519                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00520                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('userParentDesignation'), document.getElementById('suggestionsParentDesignation'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=designation');
00521                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00522                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam1'), document.getElementById('suggestionsQaosTeam1'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00523                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00524                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam2'), document.getElementById('suggestionsQaosTeam2'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00525                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00526                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam3'), document.getElementById('suggestionsQaosTeam3'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00527                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00528                                                                 designationSuggestionBox = new SuggestionBox(document.getElementById('qaosTeam4'), document.getElementById('suggestionsQaosTeam4'), './+edit&subaction=getsuggestions&forwhat=%pattern%&suggestiontype=team');
00529                                                                 designationSuggestionBox.loadingImageUrl = '$imagesFolder/ajaxloading.gif';
00530                                                                 
00531                                                         -->
00532                                                         </script>
00533 
00534                                                         </table>
00535                                         </fieldset>
00536                                 </form>
00537                         </div>
00538                 </div>
00539 
00540 ADDPERSON;
00541 // if the user team is core, then display the parent team name and designation field, otherwise disable it!
00542 
00543                 if($userTeamId == $this->getTeamIdFromTeamName("Core")){
00544                         $html .=<<<DISABLEPARENTFIELD
00545                                 <script language="javascript" type="text/javascript">
00546                                         document.getElementById("userParentTeam").disabled=false;
00547                                         document.getElementById("userParentDesignation").disabled=false;
00548                                 </script>
00549 DISABLEPARENTFIELD;
00550                 }
00551                 else if($userTeamId == $this->getTeamIdFromTeamName("Qaos")){
00552                         $html .=<<<DISABLEPARENTFIELD
00553                                 <script language="javascript" type="text/javascript">
00554                                         document.getElementById("qaosTeam1").disabled=false;
00555                                         document.getElementById("qaosTeam2").disabled=false;
00556                                         document.getElementById("qaosTeam3").disabled=false;
00557                                         document.getElementById("qaosTeam4").disabled=false;
00558                                 </script>
00559 DISABLEPARENTFIELD;
00560                 }
00561         
00562                 else 
00563                         $html .=<<<DISABLEPARENTFIELD
00564                                 <script language="javascript" type="text/javascript">
00565                                                 document.getElementById("userParentTeam").disabled=true;
00566                                                 document.getElementById("userParentDesignation").disabled=true;
00567                                                 document.getElementById("qaosTeam1").disabled=true;
00568                                                 document.getElementById("qaosTeam2").disabled=true;
00569                                                 document.getElementById("qaosTeam3").disabled=true;
00570                                                 document.getElementById("qaosTeam4").disabled=true;
00571                                 </script>
00572 DISABLEPARENTFIELD;
00573                         return $html;
00574 
00575         }
00576 
00577         function getSuggestions($pattern, $patternType = 'username') {
00578                 if($patternType == 'username') {
00579                         return getSuggestions($pattern);
00580                 }
00581                 else if($patternType == 'designation'){
00582                         $suggestionsQuery = "SELECT `qaos_designation_name` FROM `qaos_designations` WHERE `qaos_designation_name` LIKE \"%$pattern%\"" ;
00583                         $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error());
00584                         $suggestions = array($pattern);
00585                         while($suggestionsRow = mysql_fetch_row($suggestionsResult)) {
00586                                 $suggestions[] = $suggestionsRow[0];
00587                         }
00588                         return join($suggestions, ',');
00589                 }
00590                 else if($patternType == 'team'){
00591                         $suggestionsQuery = "SELECT `qaos_team_name` FROM `qaos_teams` WHERE `qaos_team_name` LIKE \"%$pattern%\"" ;
00592                         $suggestionsResult = mysql_query($suggestionsQuery) or die(mysql_error());
00593                         $suggestions = array($pattern);
00594                         while($suggestionsRow = mysql_fetch_row($suggestionsResult)) {
00595                                 $suggestions[] = $suggestionsRow[0];
00596                         }
00597                         return join($suggestions, ',');
00598 
00599                 }
00600         }
00601         function getTeamId($userId){
00602                 $query = "SELECT `qaos_teams`.`qaos_team_id` FROM `qaos_teams`,`qaos_units`,`qaos_users` WHERE `qaos_users`.`user_id`='$userId' AND `qaos_users`.`qaos_unit_id` = `qaos_units`.`qaos_unit_id` AND `qaos_units`.`qaos_team_id`=`qaos_teams`.`qaos_team_id`";
00603                 $result = mysql_query($query);
00604                 $row = mysql_fetch_assoc($result);
00605                 $teamId = $row['qaos_team_id'];
00606                 return $teamId;
00607         }
00608         function getDesignationId($userId){
00609                 $query = "SELECT `qaos_designations`.`qaos_designation_id` FROM `qaos_designations`,`qaos_units`,`qaos_users` WHERE `qaos_users`.`user_id`='$userId' AND `qaos_users`.`qaos_unit_id` = `qaos_units`.`qaos_unit_id` AND `qaos_units`.`qaos_designation_id`=`qaos_designations`.`qaos_designation_id`";
00610                 $result = mysql_query($query);
00611                 $row = mysql_fetch_assoc($result);
00612                 $designationId = $row['qaos_designation_id'];
00613                 return $designationId;
00614         }
00615         function getDesignationPriority($designationId){
00616                 $query = "SELECT `qaos_designation_priority` FROM `qaos_designations` WHERE `qaos_designation_id`=$designationId";
00617                 $result = mysql_query($query);
00618                 $row = mysql_fetch_assoc($result);
00619                 $designationPriority = $row['qaos_designation_priority'];
00620                 return $designationPriority;
00621         }
00622         function getUnitId($teamId,$designationId){
00623                 $query = "SELECT `qaos_unit_id` FROM `qaos_units` WHERE `qaos_team_id`=$teamId AND `qaos_designation_id`=$designationId";
00624                 $result = mysql_query($query);
00625                 $row = mysql_fetch_assoc($result);
00626                 $unitId = $row['qaos_unit_id'];
00627                 return $unitId;
00628         }
00629         function getUnitIdFromUserId($userId){
00630                 $query = "SELECT `qaos_unit_id` FROM `qaos_users` WHERE `user_id`=$userId";
00631                 $result = mysql_query($query);
00632                 $row = mysql_fetch_assoc($result);
00633                 $unitId = $row['qaos_unit_id'];
00634                 return $unitId;
00635                 
00636         }
00637         function getDesignationIdFromDesignationName($designation){
00638                 $query = "SELECT `qaos_designation_id` FROM `qaos_designations` WHERE `qaos_designation_name`='$designation'";
00639                 $result = mysql_query($query);
00640                 $row = mysql_fetch_row($result);
00641                 $designationId = $row[0];
00642                 return $designationId;
00643         }
00644         function getDesignationNameFromDesignationId($designationId){
00645                 $query = "SELECT `qaos_designation_name` FROM `qaos_designations` WHERE `qaos_designation_id`='$designationId'";
00646                 $result = mysql_query($query);
00647                 $row = mysql_fetch_row($result);
00648                 $designationName = $row[0];
00649                 return $designationName;
00650         }
00651         function getTeamIdFromTeamName($teamName){
00652                 $query = "SELECT `qaos_team_id` FROM `qaos_teams` WHERE `qaos_team_name`='$teamName'";
00653                 $result = mysql_query($query);
00654                 $row = mysql_fetch_row($result);
00655                 $teamId = $row[0];
00656                 return $teamId;
00657         }
00658         function getTeamNameFromTeamId($teamId){
00659                 $query = "SELECT `qaos_team_name` FROM `qaos_teams` WHERE `qaos_team_id`='$teamId'";
00660                 $result = mysql_query($query);
00661                 $row = mysql_fetch_row($result);
00662                 $teamName = $row[0];
00663                 return $teamName;
00664         }
00665         function addQaosTeamMember($userId,$qaosTeam1,$qaosTeam2,$qaosTeam3,$qaosTeam4){
00666                 
00667                 if($qaosTeam1){
00668                         $memberadd = false;
00669                         $query = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam1'";
00670                         $result = mysql_query($query);
00671                         $row = mysql_fetch_assoc($result);
00672                         $userRep11 = $row['user1'];
00673                         $userRep12 = $row['user2'];
00674                         if($userRep11 && $userRep12){
00675                                 displayerror("Sorry, this qaos member can not be added to the team. Already two members has been assigned to this team.");
00676                         }
00677                         else if(!$userRep11 && !$memberadd){
00678                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam1'";
00679                                 if($result = mysql_query($query)){
00680                                         displayinfo("User Successfully added in $qaosTeam1");
00681                                         $memberadd = true;
00682                                 }
00683                                 
00684                         }
00685                         else if(!$userRep12 && !$memberadd){
00686                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam1'";
00687                                 if($result = mysql_query($query)){
00688                                         displayinfo("User Successfully added in $qaosTeam1");
00689                                         $memberadd = true;
00690                                 }
00691                         }
00692                 }
00693                 if($qaosTeam2){
00694                         $memberadd = false;
00695                         $userRep1 = NULL;
00696                         $userRep2 = NULL;
00697                         $query2 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam2'";
00698                         $result2 = mysql_query($query2);
00699                         $row2 = mysql_fetch_assoc($result2);
00700                         $userRep1 = $row2['user1'];
00701                         $userRep2 = $row2['user2'];
00702                         if($userRep1 && $userRep2){
00703                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam2. Already two members has been assigned to this team.");
00704                         }
00705                         else if(!$userRep1 && !$memberadd){
00706                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam2'";
00707                                 if($result = mysql_query($query)){
00708                                         displayinfo("User Successfully added in $qaosTeam2");
00709                                         $memberadd = true;
00710                                 }
00711                                 
00712                         }
00713                         else if(!$userRep2 && !$memberadd){
00714                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam2'";
00715                                 if($result = mysql_query($query)){
00716                                         displayinfo("User Successfully added in $qaosTeam2");
00717                                         $memberadd = true;
00718                                 }
00719                         }
00720                 }
00721                 if($qaosTeam3){
00722                         $memberadd = false;
00723                         $userRep1 = NULL;
00724                         $userRep2 = NULL;
00725                         $query3 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam3'";
00726                         $result3 = mysql_query($query3);
00727                         $row3 = mysql_fetch_assoc($result3);
00728                         $userRep1 = $row3['user1'];
00729                         $userRep2 = $row3['user2'];
00730                         if($userRep1 && $userRep2){
00731                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam3. Already two members has been assigned to this team.");
00732                         }
00733                         else if(!$userRep1 && !$memberadd){
00734                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam3'";
00735                                 if($result = mysql_query($query)){
00736                                         displayinfo("User Successfully added in $qaosTeam3");
00737                                         $memberadd = true;
00738                                 }
00739                                 
00740                         }
00741                         else if(!$userRep2 && !$memberadd){
00742                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam3'";
00743                                 if($result = mysql_query($query)){
00744                                         displayinfo("User Successfully added in $qaosTeam3");
00745                                         $memberadd = true;
00746                                 }
00747                         }
00748                 }
00749                 if($qaosTeam4){
00750                         $memberadd = false;
00751                         $userRep1 = NULL;
00752                         $userRep2 = NULL;
00753                         $query4 = "SELECT `qaos_representative_user_id1` as user1,`qaos_representative_user_id2` as user2 FROM `qaos_teams` WHERE `qaos_team_name`='$qaosTeam4'";
00754                         $result4 = mysql_query($query4);
00755                         $row4 = mysql_fetch_assoc($result4);
00756                         $userRep1 = $row4['user1'];
00757                         $userRep2 = $row4['user2'];
00758                         if($userRep1 && $userRep2){
00759                                 displayerror("Sorry, this qaos member can not be added to $qaosTeam4. Already two members has been assigned to this team.");
00760                         }
00761                         else if(!$userRep1 && !$memberadd){
00762                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id1` = $userId WHERE `qaos_team_name` = '$qaosTeam4'";
00763                                 if($result = mysql_query($query)){
00764                                         displayinfo("User Successfully added in $qaosTeam4");
00765                                         $memberadd = true;
00766                                 }
00767                                 
00768                         }
00769                         else if(!$userRep2 && !$memberadd){
00770                                 $query = "UPDATE `qaos_teams` SET `qaos_representative_user_id2` = $userId WHERE `qaos_team_name` = '$qaosTeam4'";
00771                                 if($result = mysql_query($query)){
00772                                         displayinfo("User Successfully added in $qaosTeam4");
00773                                         $memberadd = true;
00774                                 }
00775                         }
00776                 }
00777                 
00778                 return;
00779         }
00780         function addTeamMember($email,$designation,$team,$newparentTeam,$newparentDesignation){
00781 
00782                 $userId = getUserIdFromEmail($email);
00783                 $parentUserId = $this->userId;
00784 
00788                 $parentTeamId = $this->getTeamId($parentUserId);
00789                 $parentDesignationId = $this->getDesignationId($parentUserId);
00790                 $parentUnitId = $this->getUnitId($parentTeamId,$parentDesignationId);
00791                 $parentDesignationPriority = $this->getDesignationPriority($parentDesignationId);
00792 
00793 //              get the team id of the user.
00794 
00795                 $teamId = $this->getTeamIdFromTeamName($team);
00796 
00807                 if($teamId != $parentTeamId && $parentDesignationPriority <= 3){
00808                         displayerror("You cannot add members into some other team.");
00809                         return $name;
00810                 }
00811 // get the designation id of the user being added from the designation name.
00812                 $designationId = $this->getDesignationIdFromDesignationName($designation);
00813 // now check if the parent has higher priority or not.If parent has lower priority, give an error and leave.
00814                 $designationPriority = $this->getDesignationPriority($designationId);
00815                 if($designationPriority > $parentDesignationPriority){
00816                         displayerror("You can not add members higher than your level");
00817                         return $name;
00818                 }
00819                 if(($newparentDesignation)&&($newparentTeam)){
00820                         $parentTeamId = $this->getTeamIdFromTeamName($newparentTeam);
00821                         $parentDesignationId = $this->getDesignationIdFromDesignationName($newparentDesignation);
00822                         $parentUnitId = $this->getUnitId($parentTeamId,$parentDesignationId);
00823                 }
00824 // now check if the user exists or not
00825                 $query = "SELECT `user_id`,`qaos_unit_id` FROM `qaos_users` WHERE `user_id`=$userId";
00826                 $result = mysql_query($query);
00827                 if($row = mysql_fetch_assoc($result)){
00828                         $unitId = $row['qaos_unit_id'];
00829                         $queryTeam = "SELECT `qaos_teams`.`qaos_team_name` FROM `qaos_teams`, `qaos_units` WHERE `qaos_teams`.`qaos_team_id`=`qaos_units`.`qaos_team_id` AND `qaos_units`.`qaos_unit_id`=$unitId";
00830                         $resultTeam = mysql_query($queryTeam);
00831                         $row = mysql_fetch_assoc($resultTeam);
00832                         var_dump($row);
00833                         $teamName = $row['qaos_team_name'];
00834                         displayerror("Sorry, the user can not be added. The person already exists in the ".$teamName." team.");
00835                 }
00836                 else {
00837 // Check whether the unit already exists in the database or not. If not add a new unit, and then add the user otherwise directly add the user
00838                         $queryUnits = "SELECT `qaos_unit_id` FROM `qaos_units` WHERE `qaos_team_id`=$teamId AND `qaos_designation_id`=$designationId";
00839                         $resultUnits = mysql_query($queryUnits);
00840 //if the unit exist, just add the user to the qaos_user table.
00841                         if($rowUnits = mysql_fetch_assoc($resultUnits)){
00842                                 $unitId = $rowUnits['qaos_unit_id'];
00843                                 $queryUsers = "INSERT INTO `qaos_users` (`page_modulecomponentid`,`user_id`,`qaos_unit_id`) VALUES ($this->moduleComponentId,$userId,$unitId)";
00844                                 $resultUsers = mysql_query($queryUsers);
00845                                 if($resultUsers)
00846                                         displayinfo("The User was successfully added to the team");
00847                                 else
00848                                         displayerror("There was some error in adding the user to the table");
00849                         }
00850 //if the unit does not exist, add a new unit, add the unit in the tree and add the new user.
00851                         else{
00852                                 $queryMaxUnitid = "SELECT MAX(`qaos_unit_id`) AS MAX FROM `qaos_units`";
00853                                 $resultMaxUnitid = mysql_query($queryMaxUnitid);
00854                                 $rowMaxUnitid = mysql_fetch_assoc($resultMaxUnitid);
00855                                 $unitId = 1 + $rowMaxUnitid['MAX'];
00856                                 $queryInsertUnit = "INSERT INTO `qaos_units` (`page_modulecomponentid`,`qaos_unit_id`,`qaos_team_id`,`qaos_designation_id`) VALUES ($this->moduleComponentId,$unitId,$teamId,$designationId)";
00857                                 $resultInsertUnit = mysql_query($queryInsertUnit);
00858                                 //echo $parentUnitId."two";
00859                                 $queryInsertTree = "INSERT INTO `qaos_tree` (`page_modulecomponentid`,`qaos_unit_id`,`qaos_parentunit_id`) VALUES ($this->moduleComponentId,$unitId,$parentUnitId)";
00860                                 $resultInsertTree = mysql_query($queryInsertTree);
00861 
00862                                 $queryInsertUser = "INSERT INTO `qaos_users` (`page_modulecomponentid`,`user_id`,`qaos_unit_id`) VALUES ($this->moduleComponentId,$userId,$unitId)";
00863                                 $resultInsertUser = mysql_query($queryInsertUser);
00864                                 displayinfo("The User was successfully added to the team.");
00865                         }
00866                 }
00867                 return $name;
00868         }
00869         function generateTree($moduleComponentId,$score) {
00870                 global $sourceFolder,$cmsFolder;
00871                 global $urlRequestRoot;
00872                 global $templateFolder;
00873                 $imagesFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/images";
00874                 $scriptsFolder = "$urlRequestRoot/$cmsFolder/$templateFolder/common/scripts";
00875                 $queryVersion = "SELECT `qaos_version` FROM `qaos_version` WHERE `page_modulecomponentid` = $moduleComponentId";
00876                 $resultVersion = mysql_query($queryVersion);
00877                 $row = mysql_fetch_row($resultVersion);
00878                 $version = $row[0];
00879                 $treeData .= "<h2>$version</h2> <br />";
00880                 $treeData .= '<div id="directorybrowser"><ul class="treeview" id="qaos">' .
00881                                 '<script type="text/javascript" language="javascript" src="'.$scriptsFolder.'/ddtree.js"></script>';
00882 // for all those unit id's which have no parent.. like core team!
00883                 $unitId = 0;
00884                 $treeData .= $this->getNodeHtml($unitId,$score);
00885                 $treeData .= '</ul></div>';
00886                 $treeData .= <<<TREEDATA
00887                         <style type="text/css">
00888                         #qaos li{background-color:#F7F4FF;border:#88AAEA solid 1px;margin:10px;}
00889                         </style>
00890                         <script type="text/javascript" language="javascript">
00891                         <!--
00892                                 siteMapLinks = document.getElementById('qaos').getElementsByTagName('a');
00893                                 for(i = 0; i < siteMapLinks.length; i++) {
00894                                         siteMapLinks[i].onclick = treeLinkClicked;
00895                                 }
00896 
00897                                 setupMenuDependencies("$imagesFolder", '');
00898                                 ddtreemenu.createTree("qaos", true, 5);
00899                         -->
00900                         </script>
00901 
00902 TREEDATA;
00903 
00904                 return $treeData;
00905         }
00906         function getNodeHtml($unitId,$score) {
00907                 $htmlOut = '';
00908                 $query = "SELECT `user_id`,us.`qaos_unit_id`,d.`qaos_designation_name`,tm.`qaos_team_name` FROM `qaos_users` us,`qaos_designations` d,`qaos_units` un,`qaos_tree` t,`qaos_teams` tm WHERE t.`qaos_parentunit_id`=$unitId AND us.`qaos_unit_id` = t.`qaos_unit_id` AND un.`qaos_unit_id`=us.`qaos_unit_id` AND d.`qaos_designation_id` = un.`qaos_designation_id` AND tm.`qaos_team_id`=un.`qaos_team_id` ORDER BY d.`qaos_designation_name`,tm.`qaos_team_name`";
00909                 $queryResult = mysql_query($query);
00910                 $arrayUsers = array();
00911                 $arrayUnits = array();
00912                 $arr = array();
00913                 $designation = array();
00914                 $team = array();
00915                 while($queryArray = mysql_fetch_assoc($queryResult))
00916                 {
00917                         //$arrayUsers[] = $queryArray['user_id'];
00918                         //$arrayUnits[] = $queryArray['qaos_unit_id'];
00919                         $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
00920                         $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
00921                         $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
00922                 }
00923                 foreach($arr as $unitId=>$userId)
00924                 {
00925                         $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
00926                         $userFullNameArray= array();
00927                         foreach($userId as $i)
00928                         {
00929                                 if($score){
00930                                 $userEmail = getUserEmail($i);
00931                                 $userFullName = getUserFullName($i);
00932                                 $userFullNameArray[] .=<<<USERNAME
00933                                         <a href="./+qaosadmin&subaction=viewscore&useremail=$userEmail">$userFullName</a> 
00934 USERNAME;
00935                                 }
00936                                 else 
00937                                         $userFullNameArray[] .= getUserFullName($i);
00938                         }
00939                         $htmlOut .= join($userFullNameArray,", ");
00940                         $childHtml = $this->getNodeHtml($unitId,$score);
00941                         if($childHtml != "") {
00942                                 $htmlOut .= "<ul>" . $childHtml . '</ul>';
00943                         }
00944                         $htmlOut .= "</li>";
00945                 }
00946 
00947 
00948                 return $htmlOut;
00949 /*
00950                 if(getPermissions($userId, $pageId, $action, $module)) {
00951                         $pageInfo = getPageInfo($pageId);
00952                         $pagePath = $parentPath;
00953                         if($pageInfo['page_name'] != '')
00954                                 $pagePath .= $pageInfo['page_name'] . '/';
00955 
00956                         $htmlOut .= "<li><a href=\"$pagePath\">" . getPageTitle($pageId) . '</a>';
00957 
00958                         $childrenQuery = 'SELECT `page_id` FROM `' . MYSQL_DATABASE_PREFIX  . 'pages` WHERE `page_parentid` <> `page_id` AND `page_parentid` = ' . $pageId;
00959                         $childrenResult = mysql_query($childrenQuery);
00960                         if(mysql_num_rows($childrenResult) > 0) {
00961                                 $htmlOut .= '<ul>';
00962                         }
00963                         while($childrenRow = mysql_fetch_row($childrenResult)) {
00964                                 $htmlOut .= $this->getNodeHtml($childrenRow[0], $userId, $module, $action, $pagePath);
00965                         }
00966                         if(mysql_num_rows($childrenResult) > 0)
00967                                 $htmlOut .= '</ul>';
00968                         $htmlOut .= '</li>';
00969                 }
00970                 return $htmlOut;
00971         */
00972         }
00973 
00974         public function createModule(& $moduleComponentId){
00975                 $query = "SELECT MAX(page_modulecomponentid) as MAX FROM `qaos_version` ";
00976                 $result = mysql_query($query) or die(mysql_error() . "qaos.lib L:31");
00977                 $row = mysql_fetch_assoc($result);
00978                 $compId = $row['MAX'] + 1;
00979 
00980                 $query = "INSERT INTO `qaos_version` (`page_modulecomponentid`) VALUES ('$compId')";
00981                 $result = mysql_query($query) or die(mysql_error()."article.lib L:76");
00982                 if (mysql_affected_rows()) {
00983                         $moduleComponentId = $compId;
00984                         return true;
00985                 } else
00986                         return false;
00987         }/*createModule just creates an empty qaos module*/
00988         
00989         public function actionScore($moduleComponentId){
00990                 $moduleComponentId = $this->moduleComponentId;
00991                 $userId = $this->userId;
00992                 $userEmail = getUserEmail($userId);
00993                 $designationId = $this->getDesignationId($userId);
00994                 $designationName = $this->getDesignationNameFromDesignationId($designationId);
00995                 $teamId = $this->getTeamId($userId);
00996                 $htmlOut = '';
00997                 if(isset($_GET['subaction'])){
00998                         if($_GET['subaction']=='scoringUserDone'){
00999                                 if(isset($_POST['btnSubmitScore'])){
01000                                         $targetUserEmail =$_GET['targetUserEmail'];
01001                                         $userEmail = $_GET['userEmail'];
01002                                         $targetUserId = getUserIdFromEmail($targetUserEmail);
01003                                         $userId = getUserIdFromEmail($userEmail);
01004                                         $query = "INSERT INTO `qaos_scoring`(`page_modulecomponentid`,`user_id`,`targetuser_id`,`qaos_score1`,`qaos_score2`,`qaos_score3`,`qaos_score4`,`qaos_score5`,`qaos_reason1`,`qaos_reason2`,`qaos_reason3`,`qaos_reason4`,`qaos_reason5`) VALUES($moduleComponentId,$userId,$targetUserId,{$_POST['qaos_score1']},{$_POST['qaos_score2']},{$_POST['qaos_score3']},{$_POST['qaos_score4']},{$_POST['qaos_score5']},'{$_POST['qaos_reason1']}','{$_POST['qaos_reason2']}','{$_POST['qaos_reason3']}','{$_POST['qaos_reason4']}','{$_POST['qaos_reason5']}')";
01005                                         if(mysql_query($query))
01006                                                 displayinfo("Your scores have been stored.");
01007                                         else
01008                                                 displayerror("There was some error in storing your scores");
01009                                 }
01010                                         
01011                         }
01012                         if($_GET['subaction']=='scoreUser'){                            
01013                                 if(isset($_GET['userEmail'])){
01014                                         $targetUserEmail = $_GET['userEmail'];
01015                                         $targetUserId = getUserIdFromEmail($_GET['userEmail']);
01016                                         $targetUserFullName = getUserFullName($targetUserId);
01017                                         if($targetUserId == $userId){
01018                                                 displayerror("You can not score yourself");
01019                                                 return $htmlOut;
01020                                         }
01021                                         
01022                                         $query ="SELECT * FROM `qaos_scoring` WHERE user_id=$userId AND targetuser_id=$targetUserId";
01023                                         $result = mysql_query($query);
01024                                         if(mysql_affected_rows()>0){
01025                                                 displayerror("You have already scored this person.");
01026                                                 return $htmlOut;
01027                                         }
01028                                         
01029                                         $htmlOut = "";
01030                                         
01031                                         $htmlOut .= <<<SCOREUSER
01032                                         <div class="scoreuser">
01033                                                 <form id="scoreuser" method="POST" onsubmit="return checkProfileForm(this)" action="./+score&userEmail=$userEmail&targetUserEmail=$targetUserEmail&subaction=scoringUserDone">
01034                                                         <fieldset style="width:80%">
01035                                                                 <legend><b>Score, $targetUserFullName</b></legend>
01036                                                                 <table>
01037                                                                         <tr>
01038                                                                                 <td>
01039                                                                                         <b>Question No. 1:</b><br />
01040                                                                                         Is the person regular and punctual in his/her work/meetings?<br />
01041                                                                                 </td>
01042                                                                                 
01043                                                                         </tr>
01044                                                                         <tr>
01045                                                                                 <td>
01046                                                                                         <br />
01047                                                                                 </td>
01048                                                                         </tr>
01049                                                                         <tr>
01050                                                                                 <td> Your Score:
01051                                                                                 </td>   
01052                                                                                 <td>
01053                                                                                         <select name="qaos_score1" id="qaos_score1">
01054                                                                                                 <option value="1">1</option>
01055                                                                                                 <option value="2">2</option>
01056                                                                                                 <option value="3">3</option>
01057                                                                                                 <option value="4">4</option>
01058                                                                                                 <option value="5">5</option>
01059                                                                                                 <option value="6">6</option>
01060                                                                                                 <option value="7">7</option>
01061                                                                                                 <option value="8">8</option>
01062                                                                                                 <option value="9">9</option>
01063                                                                                                 <option value="10">10</option>
01064                                                                                         </select>
01065                                                                                 </td>
01066                                                                         </tr>
01067                                                                         <tr>
01068                                                                                 <td> Your Reason/Comments:
01069                                                                                 </td>
01070                                                                                 <td>
01071                                                                                         <textarea rows="3" columns="20" name="qaos_reason1" id="qaos_reason1" title="Enter your comments/reason here"></textarea>
01072                                                                                 </td>   
01073                                                                         </tr>
01074                                                                         <tr>
01075                                                                                 <td>
01076                                                                                         <b>Question No. 2:</b><br />
01077                                                                                         Is this person a team worker and co ordinates with others well?<br />
01078                                                                                 </td>
01079                                                                                 
01080                                                                         </tr>
01081                                                                         <tr>
01082                                                                                 <td>
01083                                                                                         <br />
01084                                                                                 </td>
01085                                                                         </tr>
01086                                                                         <tr>
01087                                                                                 <td> Your Score:
01088                                                                                 </td>   
01089                                                                                 <td>
01090                                                                                         <select name="qaos_score2" id="qaos_score2">
01091                                                                                                 <option value="1">1</option>
01092                                                                                                 <option value="2">2</option>
01093                                                                                                 <option value="3">3</option>
01094                                                                                                 <option value="4">4</option>
01095                                                                                                 <option value="5">5</option>
01096                                                                                                 <option value="6">6</option>
01097                                                                                                 <option value="7">7</option>
01098                                                                                                 <option value="8">8</option>
01099                                                                                                 <option value="9">9</option>
01100                                                                                                 <option value="10">10</option>
01101                                                                                         </select>
01102                                                                                 </td>
01103                                                                         </tr>
01104                                                                         <tr>
01105                                                                                 <td> Your Reason/Comments:
01106                                                                                 </td>
01107                                                                                 <td>
01108                                                                                         <textarea rows="3" columns="20" name="qaos_reason2" id="qaos_reason2" title="Enter your comments/reason here"></textarea>
01109                                                                                 </td>   
01110                                                                         </tr>
01111                                                                         <tr>
01112                                                                                 <td>
01113                                                                                         <b>Question No. 3:</b><br />
01114                                                                                         How is his/her promptness in completing work?<br />
01115                                                                                 </td>
01116                                                                                 
01117                                                                         </tr>
01118                                                                         <tr>
01119                                                                                 <td>
01120                                                                                         <br />
01121                                                                                 </td>
01122                                                                         </tr>
01123                                                                         <tr>
01124                                                                                 <td> Your Score:
01125                                                                                 </td>   
01126                                                                                 <td>
01127                                                                                         <select name="qaos_score3" id="qaos_score3">
01128                                                                                                 <option value="1">1</option>
01129                                                                                                 <option value="2">2</option>
01130                                                                                                 <option value="3">3</option>
01131                                                                                                 <option value="4">4</option>
01132                                                                                                 <option value="5">5</option>
01133                                                                                                 <option value="6">6</option>
01134                                                                                                 <option value="7">7</option>
01135                                                                                                 <option value="8">8</option>
01136                                                                                                 <option value="9">9</option>
01137                                                                                                 <option value="10">10</option>
01138                                                                                         </select>
01139                                                                                 </td>
01140                                                                         </tr>
01141                                                                         <tr>
01142                                                                                 <td> Your Reason/Comments:
01143                                                                                 </td>
01144                                                                                 <td>
01145                                                                                         <textarea rows="3" columns="20" name="qaos_reason3" id="qaos_reason3" title="Enter your comments/reason here"></textarea>
01146                                                                                 </td>   
01147                                                                         </tr>
01148                                                                         <tr>
01149                                                                                 <td>
01150                                                                                         <b>Question No. 4:</b><br />
01151                                                                                         How is his/her interest/enthusiasm/initiative in his/her work?<br />
01152                                                                                 </td>
01153                                                                                 
01154                                                                         </tr>
01155                                                                         <tr>
01156                                                                                 <td>
01157                                                                                         <br />
01158                                                                                 </td>
01159                                                                         </tr>
01160                                                                         <tr>
01161                                                                                 <td> Your Score:
01162                                                                                 </td>   
01163                                                                                 <td>
01164                                                                                         <select name="qaos_score4" id="qaos_score4">
01165                                                                                                 <option value="1">1</option>
01166                                                                                                 <option value="2">2</option>
01167                                                                                                 <option value="3">3</option>
01168                                                                                                 <option value="4">4</option>
01169                                                                                                 <option value="5">5</option>
01170                                                                                                 <option value="6">6</option>
01171                                                                                                 <option value="7">7</option>
01172                                                                                                 <option value="8">8</option>
01173                                                                                                 <option value="9">9</option>
01174                                                                                                 <option value="10">10</option>
01175                                                                                         </select>
01176                                                                                 </td>
01177                                                                         </tr>
01178                                                                         <tr>
01179                                                                                 <td> Your Reason/Comments:
01180                                                                                 </td>
01181                                                                                 <td>
01182                                                                                         <textarea rows="3" columns="20" name="qaos_reason4" id="qaos_reason4" title="Enter your comments/reason here"></textarea>
01183                                                                                 </td>   
01184                                                                         </tr>
01185                                                                         <tr>
01186                                                                                 <td>
01187                                                                                         <b>Question No. 5:</b><br />
01188                                                                                         How is his/her potential managerial abilities?<br />
01189                                                                                 </td>
01190                                                                                 
01191                                                                         </tr>
01192                                                                         <tr>
01193                                                                                 <td>
01194                                                                                         <br />
01195                                                                                 </td>
01196                                                                         </tr>
01197                                                                         <tr>
01198                                                                                 <td> Your Score:
01199                                                                                 </td>   
01200                                                                                 <td>
01201                                                                                         <select name="qaos_score5" id="qaos_score5">
01202                                                                                                 <option value="1">1</option>
01203                                                                                                 <option value="2">2</option>
01204                                                                                                 <option value="3">3</option>
01205                                                                                                 <option value="4">4</option>
01206                                                                                                 <option value="5">5</option>
01207                                                                                                 <option value="6">6</option>
01208                                                                                                 <option value="7">7</option>
01209                                                                                                 <option value="8">8</option>
01210                                                                                                 <option value="9">9</option>
01211                                                                                                 <option value="10">10</option>
01212                                                                                         </select>
01213                                                                                 </td>
01214                                                                         </tr>
01215                                                                         <tr>
01216                                                                                 <td> Your Reason/Comments:
01217                                                                                 </td>
01218                                                                                 <td>
01219                                                                                         <textarea rows="3" columns="20" name="qaos_reason5" id="qaos_reason5" title="Enter your comments/reason here"></textarea>
01220                                                                                 </td>   
01221                                                                         </tr>
01222                                                                         <tr>
01223                                                                                 <td>
01224                                                                                         <input type="submit" name="btnSubmitScore" id="submitbutton" value="Save Scores">
01225                                                                                 </td>
01226                                                                         </tr>
01227                                                                         
01228                                                                 </table>
01229                                                         </fieldset>
01230                                                 </form>
01231                                         </div>
01232 SCOREUSER;
01233                                         return $htmlOut;
01234                                         }
01235                                 }
01236                         }
01237                 
01238                 $query = "SELECT `user_id`,un.`qaos_unit_id`,d.`qaos_designation_name`,t.`qaos_team_name` FROM `qaos_users` u,`qaos_designations` d,`qaos_teams` t,`qaos_units` un WHERE un.`qaos_unit_id` = u.`qaos_unit_id` AND un.`qaos_team_id`=$teamId AND d.`qaos_designation_id` = un.`qaos_designation_id` AND t.`qaos_team_id`=un.`qaos_team_id`" ;
01239                 $queryResult = mysql_query($query);
01240                 $arrayUsers = array();
01241                 $arrayUnits = array();
01242                 $arr = array();
01243                 $designation = array();
01244                 $team = array();
01245                 while($queryArray = mysql_fetch_assoc($queryResult))
01246                 {
01247                         $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01248                         $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01249                         $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01250                 }
01251                 foreach($arr as $unitId=>$userId)
01252                 {
01253                         $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01254                         $userFullNameArray= array();
01255                         foreach($userId as $i)
01256                         {
01257                                 $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01258                                 $htmlOut .= getUserFullName($i);
01259                                 $htmlOut .= "</a>";
01260                                 $htmlOut .= "<br />";
01261                                 //$userFullNameArray[] .= getUserFullName($i);
01262                         }
01263                         //$htmlOut .= join($userFullNameArray,", ");
01264                         $htmlOut .= "</li>";
01265                 }
01266                 $htmlOut .= "<br /><br />";
01267                 $teamName = $this->getTeamNameFromTeamId($teamId);
01268                 if($teamName=="Core"){
01269                         $unitId = $this->getUnitIdFromUserId($this->userId);
01270                         $query = "SELECT us.user_id,tr.qaos_unit_id,d.qaos_designation_name, tm.qaos_team_name FROM `qaos_tree` tr JOIN qaos_units un ON (tr.qaos_unit_id = un.qaos_unit_id) JOIN qaos_teams tm ON (un.qaos_team_id = tm.qaos_team_id) JOIN qaos_designations d ON (un.qaos_designation_id = d.qaos_designation_id) JOIN qaos_users us ON (un.qaos_unit_id = us.qaos_unit_id) WHERE tr.qaos_parentunit_id=$unitId";
01271                         $queryResult = mysql_query($query);
01272                         $arrayUsers = array();
01273                         $arrayUnits = array();
01274                         $arr = array();
01275                         $designation = array();
01276                         $team = array();
01277                         while($queryArray = mysql_fetch_assoc($queryResult))
01278                         {
01279                                 $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01280                                 $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01281                                 $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01282                         }
01283                         foreach($arr as $unitId=>$userId)
01284                         {
01285                                 $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01286                                 $userFullNameArray= array();
01287                                 foreach($userId as $i)
01288                                 {
01289                                         $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01290                                         $htmlOut .= getUserFullName($i);
01291                                         $htmlOut .= "</a>";
01292                                         $htmlOut .= "<br />";
01293                                         //$userFullNameArray[] .= getUserFullName($i);
01294                                 }
01295                                 //$htmlOut .= join($userFullNameArray,", ");
01296                                 $htmlOut .= "</li>";
01297                         }
01298                 }
01299                 if($teamName=="Qaos"){
01300                         $unitId = $this->getUnitIdFromUserId($this->userId);
01301                         $query = "SELECT us.`user_id`,u.`qaos_unit_id`,d.`qaos_designation_name`,t.`qaos_team_name` FROM `qaos_units` u,`qaos_designations` d,`qaos_users` us,`qaos_teams` t WHERE u.`qaos_unit_id`= us.`qaos_unit_id` AND u.`qaos_designation_id`= d.`qaos_designation_id` AND u.`qaos_team_id` = t.`qaos_team_id` AND u.`qaos_team_id` IN (SELECT t.`qaos_team_id` FROM `qaos_teams` t WHERE t.`qaos_representative_user_id1` = $this->userId OR t.`qaos_representative_user_id2` = $this->userId)";
01302                         $result = mysql_query($query);
01303                         $arrayUsers = array();
01304                         $arrayUnits = array();
01305                         $arr = array();
01306                         $designation = array();
01307                         $team = array();
01308                         while($queryArray = mysql_fetch_assoc($result))
01309                         {
01310                                 $designation[$queryArray['qaos_unit_id']] = $queryArray['qaos_designation_name'];
01311                                 $team[$queryArray['qaos_unit_id']] = $queryArray['qaos_team_name'];
01312                                 
01313                                 $arr[$queryArray['qaos_unit_id']][] = $queryArray['user_id'];
01314                         }
01315                         foreach($arr as $unitId=>$userId)
01316                         {
01317                                 $htmlOut .= "<li><i>".$team[$unitId]." -</i> <b>".$designation[$unitId]."</b> : <br />";
01318                                 $userFullNameArray= array();
01319                                 foreach($userId as $i)
01320                                 {
01321                                         $htmlOut .= "<a href=\"./+score&subaction=scoreUser&userEmail=".getUserEmail($i)."\">";
01322                                         $htmlOut .= getUserFullName($i);
01323                                         $htmlOut .= "</a>";
01324                                         $htmlOut .= "<br />";
01325                                         //$userFullNameArray[] .= getUserFullName($i);
01326                                 }
01327                                 //$htmlOut .= join($userFullNameArray,", ");
01328                                 $htmlOut .= "</li>";
01329                         }       
01330                         
01331                 }
01332                                 
01333                 return $htmlOut;
01334         }
01335         public function deleteModule($moduleComponentId){
01336         }
01337         public function copyModule($moduleComponentId){
01338         }
01339 }

Generated on Sun Jan 2 2011 04:55:32 for Pragyan CMS by  doxygen 1.7.1