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

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1