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

Generated on Fri Dec 13 2013 11:57:54 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1