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

classes/class.ilObjectStatusGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00032 class ilObjectStatusGUI
00033 {
00034         var $lng;
00035         var $ilias;
00036         var $tpl;
00037         var $tree;
00038         var $rbacsystem;
00039         var $cur_ref_id;
00040         var $cmd;
00041         var $mode;
00042         var $ctrl;
00043 
00048         function ilObjectStatusGUI(&$a_obj)
00049         {
00050                 global $ilUser,$ilCtrl,$ilias,$ilErr,$lng,$rbacreview;
00051 
00052                 $this->ctrl =& $ilCtrl;
00053                 $this->object =& $a_obj;
00054                 
00055                 $this->tpl = new ilTemplate("tpl.info_layout.html", false, false);
00056                 $this->tpl->setVariable("INFO_REMARK_INTERRUPTED",$lng->txt('info_remark_interrupted'));
00057 
00058                 if (empty($_POST['Fuserid']))
00059                 {
00060                         $this->user =& $ilUser;
00061                 }
00062                 else
00063                 {
00064                         if (is_numeric($_POST['Fuserid']))
00065                         {
00066                                 $this->user = $ilias->obj_factory->getInstanceByObjId($_POST['Fuserid'],false);
00067                         }
00068                         else
00069                         {
00070                                 include_once('class.ilObjUser.php');
00071                                 $user_id = ilObjUser::_lookupId($_POST['Fuserid']);
00072                                 $this->user = $ilias->obj_factory->getInstanceByObjId($user_id,false);
00073                         }
00074 
00075                         if ($this->user === false)
00076                         {
00077                                 $this->user =& $ilUser;
00078                                 $ilErr->raiseError($lng->txt("info_err_user_not_exist"),$ilErr->MESSAGE);
00079                         }
00080                 }
00081                 
00082                 // get all user roles and all valid roles in scope
00083                 $this->user_roles = $rbacreview->assignedRoles($this->user->getId());
00084                 $this->global_roles = $rbacreview->getGlobalRoles();
00085                 $this->valid_roles = $rbacreview->getParentRoleIds($this->object->getRefId());
00086                 $this->assigned_valid_roles = $this->getAssignedValidRoles();
00087 
00088                 $this->getPermissionInfo();
00089                 
00090                 $this->getRoleAssignmentInfo();
00091                 
00092                 $this->getObjectSummary();
00093 
00094         }
00095 
00099         function &executeCommand()
00100         {
00101                 $next_class = $this->ctrl->getNextClass($this);
00102                 $this->ctrl->setCmd("");
00103         }
00104         
00105         function &__initTableGUI()
00106         {
00107                 include_once "class.ilTableGUI.php";
00108 
00109                 return new ilTableGUI(0,false);
00110         }
00111         
00112         function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
00113         {
00114         global $lng;
00115 
00116                 $tbl->disable('footer');
00117                 $tbl->disable('linkbar');
00118                 $tbl->disable('hits');
00119                 $tbl->disable('sort');
00120 
00121                 $tbl->setLimit(0);
00122                 $tbl->setData($result_set);
00123         }
00124         
00125         function __showPermissionsTable($a_result_set)
00126         {
00127         global $lng;
00128 
00129         $tbl =& $this->__initTableGUI();
00130                 $tpl =& $tbl->getTemplateObject();
00131 
00132                 // title & header columns
00133                 $tbl->setTitle($lng->txt("info_access_permissions"),"icon_perm_b.gif",$lng->txt("info_access_permissions"));
00134 
00135                 //user must be member
00136                 $tbl->setHeaderNames(array("",$lng->txt("operation"),$lng->txt("info_from_role")));
00137                 //$tbl->setHeaderVars(array("operation","granted"),$this->ctrl->getParameterArray($this->object,"",false));
00138                 $tbl->setHeaderVars(array("","operation","role"),"");
00139                 $tbl->setColumnWidth(array("1%","39%","60%"));
00140 
00141 
00142                 $this->__setTableGUIBasicData($tbl,$a_result_set);
00143                 $tbl->setStyle('table','std');
00144                 $tbl->render();
00145                 $this->tpl->setVariable('INFO_PERMISSIONS',$tbl->tpl->get());
00146                 
00147                 return $tbl->tpl->get();
00148         }
00149         
00150         function __showRolesTable($a_result_set)
00151         {
00152         global $lng;
00153 
00154         $tbl =& $this->__initTableGUI();
00155                 $tpl =& $tbl->getTemplateObject();
00156 
00157                 // title & header columns
00158                 $tbl->setTitle($lng->txt("info_available_roles"),"icon_rolf_b.gif",$lng->txt("info_available_roles"));
00159 
00160                 $tbl->setHeaderNames(array("",$lng->txt("role"),str_replace(" ","&nbsp;",$lng->txt("info_permission_source")),str_replace(" ","&nbsp;",$lng->txt("info_permission_origin"))));
00161                 $tbl->setColumnWidth(array("1%","19%","40%","40%"));
00162                 $this->__setTableGUIBasicData($tbl,$a_result_set);
00163                 $tbl->setStyle('table','std');
00164                 $tbl->render();
00165                 $this->tpl->setVariable('INFO_ROLES',$tbl->tpl->get());
00166                 
00167                 return $tbl->tpl->get();
00168         }
00169         
00170         function __showObjectSummaryTable($a_result_set)
00171         {
00172         global $lng;
00173 
00174         $tbl =& $this->__initTableGUI();
00175                 $tpl =& $tbl->getTemplateObject();
00176                 
00177                 $class_name = get_class($this->object)."gui";
00178                 
00179                 $tpl->setCurrentBlock("tbl_form_header");
00180                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormActionByClass($class_name,"info"));
00181                 $tpl->parseCurrentBlock();
00182 
00183                 $tpl->setCurrentBlock("tbl_action_row");
00184                 
00185         $tpl->setCurrentBlock("plain_button");
00186                 $tpl->setVariable("PBTN_NAME","info");
00187                 $tpl->setVariable("PBTN_VALUE",$lng->txt("info_change_user_view"));
00188                 $tpl->parseCurrentBlock();
00189                 $tpl->setCurrentBlock("plain_buttons");
00190                 $tpl->parseCurrentBlock();
00191                 
00192                 $tpl->setVariable("COLUMN_COUNTS",7);
00193                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("spacer.gif"));
00194 
00195                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00196 
00197                 // title & header columns
00198                 $tbl->setTitle($lng->txt("info_access_and_status_info"),"icon_".$this->object->getType()."_b.gif",$lng->txt("summary"));
00199 
00200                 //user must be member
00201                 $tbl->setHeaderNames(array("&nbsp;",$lng->txt("info_enter_login_or_id")));
00202                 //$tbl->setHeaderVars(array("operation","granted"),$this->ctrl->getParameterArray($this->object,"",false));
00203                 $tbl->setHeaderVars(array("",""),"");
00204                 $tbl->setColumnWidth(array("15%","85%"));
00205 
00206 
00207                 $this->__setTableGUIBasicData($tbl,$a_result_set);
00208                 //$tbl->setStyle('table','std');
00209                 $tbl->render();
00210                 $this->tpl->setVariable('INFO_SUMMARY',$tbl->tpl->get());
00211                 
00212                 return $tbl->tpl->get();
00213         }
00214 
00215         function getHTML()
00216         {
00217                 return $this->tpl->get();
00218         }
00219         
00220         function getAssignedValidRoles()
00221         {
00222                 global $rbacreview;
00223                 
00224                 include_once ('class.ilObjRole.php');
00225 
00226                 $assigned_valid_roles = array();
00227 
00228                 foreach ($this->valid_roles as $role)
00229                 {
00230                         if (in_array($role['obj_id'],$this->user_roles))
00231                         {
00232                                 if ($role["obj_id"] == SYSTEM_ROLE_ID)
00233                                 {
00234                                         // get all possible operation of current object
00235                                         $ops_list = getOperationList($this->object->getType());
00236                                         
00237                                         foreach ($ops_list as $ops_data)
00238                                         {
00239                                                 $ops[] = (int) $ops_data['ops_id'];
00240                                         }
00241                                         
00242                                         $role['ops'] = $ops;
00243                                 }
00244                                 else
00245                                 {
00246                                         $role['ops'] = $rbacreview->getRoleOperationsOnObject($role["obj_id"],$this->object->getRefId());
00247                                 }
00248                                 
00249                                 $role['translation'] = str_replace(" ","&nbsp;",ilObjRole::_getTranslation($role["title"]));
00250                                 $assigned_valid_roles[] = $role;
00251                         }
00252                 }
00253                 
00254                 return $assigned_valid_roles;
00255         }
00256         
00257         function getPermissionInfo()
00258         {
00259                 global $ilAccess,$lng,$rbacreview,$ilUser;
00260 
00261                 // icon handlers
00262                 $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$lng->txt("info_assigned")."\" title=\"".$lng->txt("info_assigned")."\" border=\"0\" vspace=\"0\"/>";
00263                 $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.gif")."\" alt=\"".$lng->txt("info_not_assigned")."\" title=\"".$lng->txt("info_not_assigned")."\" border=\"0\" vspace=\"0\"/>";
00264                 
00265                 // get all possible operation of current object
00266                 $ops_list = getOperationList($this->object->getType());
00267                 
00268                 $counter = 0;
00269 
00270                 // check permissions of user
00271                 foreach ($ops_list as $ops)
00272                 {
00273                         $access = $ilAccess->doRBACCheck($ops['operation'],"info",$this->object->getRefId(),$this->user->getId());
00274 
00275                         $result_set[$counter][] = $access ? $icon_ok : $icon_not_ok;
00276                         $result_set[$counter][] = $lng->txt($this->object->getType()."_".$ops['operation']);
00277                         
00278                         $list_role = "";
00279                         
00280                         // get operations on object for each assigned role to user
00281                         foreach ($this->assigned_valid_roles as $role)
00282                         {
00283                                 if (in_array($ops['ops_id'],$role['ops']))
00284                                 {
00285                                         $list_role[] = $role['translation'];
00286                                 }
00287                         }
00288                         
00289                         if (empty($list_role))
00290                         {
00291                                 $roles_formatted = $lng->txt('none');
00292                         }
00293                         else
00294                         {
00295                                 $roles_formatted = implode("<br/>",$list_role);
00296                         }
00297 
00298                         $result_set[$counter][] = $roles_formatted;
00299         
00300                         ++$counter;
00301                 }
00302 
00303                 return $this->__showPermissionsTable($result_set);
00304         }
00305         
00306         function getRoleAssignmentInfo()
00307         {
00308                 global $lng,$rbacreview,$tree;
00309 
00310                 // icon handlers
00311                 $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$lng->txt("info_assigned")."\" title=\"".$lng->txt("info_assigned")."\" border=\"0\" vspace=\"0\"/>";
00312                 $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.gif")."\" alt=\"".$lng->txt("info_not_assigned")."\" title=\"".$lng->txt("info_not_assigned")."\" border=\"0\" vspace=\"0\"/>";
00313 
00314                 $path = array_reverse($tree->getPathId($this->object->getRefId()));
00315                 
00316                 //var_dump("<pre>",$valid_roles,$parent_roles,"</pre>");
00317 
00318                 include_once ('class.ilObjRole.php');
00319 
00320                 $counter = 0;
00321 
00322                 foreach ($this->valid_roles as $role)
00323                 {
00324                         $result_set[$counter][] = in_array($role['obj_id'],$this->user_roles) ? $icon_ok : $icon_not_ok;
00325                         $result_set[$counter][] = str_replace(" ","&nbsp;",ilObjRole::_getTranslation($role["title"]));
00326                         
00327                         if ($role['role_type'] != "linked")
00328                         {
00329                                 $result_set[$counter][] = "";
00330                         }
00331                         else
00332                         {
00333                                 $rolfs = $rbacreview->getFoldersAssignedToRole($role["obj_id"]);
00334 
00335                                 // ok, try to match the next rolf in path
00336                                 foreach ($path as $node)
00337                                 {
00338                                         if ($node == 1)
00339                                         {
00340                                                 break;
00341                                         }
00342                                 
00343                                         $rolf = $rbacreview->getRoleFolderOfObject($node);
00344 
00345                                         if (in_array($rolf['ref_id'],$rolfs))
00346                                         {
00347                                                 $nodedata = $tree->getNodeData($node);
00348                                                 $result_set[$counter][] = $nodedata["title"];
00349                                                 break;
00350                                         }                                                       
00351                                 }
00352                         }
00353                         
00354                         if (in_array($role['obj_id'],$this->global_roles))
00355                         {
00356                                 $result_set[$counter][] = $lng->txt("global");
00357                         }
00358                         else
00359                         {
00360                                 $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
00361                                 $parent_node = $tree->getParentNodeData($rolf[0]);
00362                                 $result_set[$counter][] = $parent_node["title"];
00363                         }
00364                                         
00365                         ++$counter;     
00366                 }
00367                 
00368                 return $this->__showRolesTable($result_set);
00369         }
00370         
00371         function getObjectSummary()
00372         {
00373                 global $lng,$rbacreview,$ilAccess,$ilias;
00374                 $infos = array();
00375                 
00376                 $input_field = "<input class=\"std\" type=\"input\" name=\"Fuserid\" value=\"".$this->user->getLogin()."\"/>";
00377 
00378                 $result_set[0][] = "<b>".$lng->txt("info_view_of_user")."</b>";
00379                 $result_set[0][] = $input_field."&nbsp;(".$this->user->getFullname().") (#".$this->user->getId().")";
00380 
00381                 $assigned_valid_roles = array();
00382 
00383                 foreach ($this->assigned_valid_roles as $role)
00384                 {
00385                         $assigned_valid_roles[] = $role["translation"];
00386                 }
00387                 
00388                 $roles_str = implode(", ",$assigned_valid_roles);
00389                         
00390                 $result_set[1][] = "<b>".$lng->txt("roles")."</b>";
00391                 $result_set[1][] = $roles_str;
00392                 
00393                 /*
00394                 $result_set[2][] = "<b>".$lng->txt("object")."</b>";
00395                 $result_set[2][] = $this->object->getTitle()." (#".$this->object->getId().") (ref#".$this->object->getRefId().")";
00396 
00397                 $result_set[3][] = "<b>".$lng->txt("type")."</b>";
00398                 $result_set[3][] = $lng->txt("obj_".$this->object->getType());
00399                 */
00400                 $result_set[4][] = "<b>".$lng->txt("status")."</b>";
00401 
00402                 $ilAccess->clear();
00403                 $ilAccess->doTreeCheck("visible","info",$this->object->getRefId(),$this->user->getId());
00404                 $infos = array_merge($infos,$ilAccess->getInfo());
00405 
00406                 $ilAccess->clear();
00407                 $ilAccess->doPathCheck("visible","info",$this->object->getRefId(),$this->user->getId(),true);
00408                 $infos = array_merge($infos,$ilAccess->getInfo());
00409 
00410                 $ilAccess->clear();
00411                 $ilAccess->doConditionCheck("read","info",$this->object->getRefId(),$this->user->getId(),$this->object->getId(),$this->object->getType());
00412                 $infos = array_merge($infos,$ilAccess->getInfo());
00413                 
00414                 $cmds = $this->getCommands($this->object->getType());
00415 
00416                 $ilAccess->clear();             
00417                 foreach ($cmds as $cmd)
00418                 {
00419 
00420                         $ilAccess->doStatusCheck($cmd['permission'],$cmd['cmd'],$this->object->getRefId(),$this->user->getId(),$this->object->getId(),$this->object->getType());
00421                         $infos = array_merge($infos,$ilAccess->getInfo());
00422                 }
00423 
00424                 $alert = "il_ItemAlertProperty";
00425                 $okay = "il_ItemOkayProperty";
00426 
00427                 if (!$infos)
00428                 {
00429                         $text = "<span class=\"".$okay."\">".$lng->txt("access")."</span><br/> ";
00430                 }
00431                 else
00432                 {
00433                         foreach ($infos as $info)
00434                         {
00435                                 switch ($info['type'])
00436                                 {
00437                                         case IL_STATUS_MESSAGE:
00438                                                 $text .= "<span class=\"".$okay."\">".$info['text']."</span><br/> ";
00439                                                 break;
00440                                                 
00441                                         case IL_NO_PARENT_ACCESS:
00442                                                 $obj = $ilias->obj_factory->getInstanceByRefId($info['data']);
00443                                                 $text .= "<span class=\"".$alert."\">".$info['text']." (".$lng->txt("obj_".$obj->getType())." #".$obj->getId().": ".$obj->getTitle().")</span><br/> ";
00444                                                 break;
00445                                                 
00446                                                 
00447                                         default:
00448                                                 $text .= "<span class=\"".$alert."\">".$info['text']."</span><br/> ";
00449                                                 break;
00450                                         
00451                                 }
00452                         }
00453                 }
00454 
00455                 $result_set[4][] = $text;
00456 
00457                 return $this->__showObjectSummaryTable($result_set);
00458         }
00459         
00460         function getCommands($a_type)
00461         {
00462                 global $objDefinition;
00463                                 
00464                 $class = $objDefinition->getClassName($a_type);
00465                 $location = $objDefinition->getLocation($a_type);
00466                 $full_class = "ilObj".$class."Access";
00467                 include_once($location."/class.".$full_class.".php");
00468                 
00469                 $cmds = call_user_func(array($full_class, "_getCommands"));
00470                 
00471                 array_push($cmds,array('permission' => 'visible','cmd' => 'info'));
00472                 
00473                 return $cmds;
00474         }
00475 } // END class.ilObjectStatus
00476 
00477 ?>

Generated on Fri Dec 13 2013 10:18:27 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1