Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 class ilObjectGUIAdapter
00035 {
00036 var $gui_obj;
00037 var $ilias;
00038 var $tpl;
00039 var $lng;
00040 var $objDefinition;
00041
00042 var $cmd;
00043 var $id;
00044 var $call_by_reference;
00045
00050 function ilObjectGUIAdapter($a_id,$a_call_by_reference,$a_prepare_output = true,$a_cmd = '')
00051 {
00052 global $ilias,$tpl,$objDefinition,$lng;
00053
00054
00055 $this->ilias =& $ilias;
00056 $this->tpl =& $tpl;
00057 $this->lng =& $lng;
00058 $this->objDefinition =& $objDefinition;
00059
00060 $this->setCommand($a_cmd);
00061 $this->id = $a_id;
00062 $this->call_by_reference = $a_call_by_reference;
00063
00064 $this->__initGUIObject($a_call_by_reference,$a_prepare_output);
00065 }
00066
00067 function getId()
00068 {
00069 return $this->id;
00070 }
00071 function setCommand($a_cmd)
00072 {
00073 if($a_cmd == "gateway" || $a_cmd == "post")
00074 {
00075 @$this->cmd = key($_POST["cmd"]);
00076 }
00077 else
00078 {
00079 $this->cmd = $a_cmd;
00080 }
00081 }
00082 function getCommand()
00083 {
00084 return $this->cmd;
00085 }
00086 function getType()
00087 {
00088 return $this->type;
00089 }
00090 function setType($a_type)
00091 {
00092 $this->type = $a_type;
00093 }
00094
00095 function performAction()
00096 {
00097 if($this->getCommand())
00098 {
00099 $method = $this->getCommand()."Object";
00100 }
00101 else
00102 {
00103 $method = $this->objDefinition->getFirstProperty($this->getType())."Object";
00104 }
00105 $this->gui_obj->$method();
00106
00107 return true;
00108 }
00113 function setAdminTabs()
00114 {
00115 global $rbacsystem;
00116
00117 $tabs = array();
00118 $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
00119
00120 $properties = $this->objDefinition->getProperties($this->getType());
00121
00122 foreach($properties as $key => $row)
00123 {
00124 $tabs[] = array($row["lng"], $row["name"]);
00125 }
00126
00127
00128 if ($this->call_by_reference === false)
00129 {
00130 $object_link = "&obj_id=".$_GET["obj_id"];
00131 }
00132
00133 foreach ($tabs as $row)
00134 {
00135 $i++;
00136
00137 if ($row[1] == $this->getCommand())
00138 {
00139 $tabtype = "tabactive";
00140 $tab = $tabtype;
00141 }
00142 else
00143 {
00144 $tabtype = "tabinactive";
00145 $tab = "tab";
00146 }
00147
00148 $show = true;
00149
00150
00151 if($this->call_by_reference)
00152 {
00153
00154 switch ($row[1])
00155 {
00156 case 'view':
00157 if (!$rbacsystem->checkAccess('visible',$this->getId()))
00158 {
00159 $show = false;
00160 }
00161 break;
00162
00163 case 'edit':
00164 if (!$rbacsystem->checkAccess('write',$this->getId()))
00165 {
00166 $show = false;
00167 }
00168 break;
00169
00170 case 'perm':
00171 if (!$rbacsystem->checkAccess('edit_permission',$this->getId()))
00172 {
00173 $show = false;
00174 }
00175 break;
00176 case 'trash':
00177 if (!$this->gui_obj->tree->getSavedNodeData($this->getId()))
00178 {
00179 $show = false;
00180 }
00181 break;
00182
00183 case 'newmembers':
00184 case 'members':
00185 if (!$rbacsystem->checkAccess('write',$this->getId()))
00186 {
00187 $show = false;
00188 }
00189 break;
00190
00191 }
00192 }
00193
00194 if (!$show)
00195 {
00196 continue;
00197 }
00198
00199 $this->tpl->setCurrentBlock("tab");
00200 $this->tpl->setVariable("TAB_TYPE", $tabtype);
00201 $this->tpl->setVariable("TAB_TYPE2", $tab);
00202 $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
00203 $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
00204 $this->tpl->setVariable("TAB_LINK", $this->gui_obj->tab_target_script."?ref_id=".$this->getId().$object_link."&cmd=".$row[1]);
00205 $this->tpl->setVariable("TAB_TEXT", $this->gui_obj->lng->txt($row[0]));
00206 $this->tpl->parseCurrentBlock();
00207 }
00208 }
00209
00210
00211
00212 function __initGUIObject($a_call_by_reference,$a_prepare_output = true)
00213 {
00214 global $objDefinition;
00215
00216 include_once "./classes/class.ilObjectFactory.php";
00217
00218
00219 if($a_call_by_reference)
00220 {
00221 $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->getId());
00222 }
00223 else
00224 {
00225 $tmp_obj =& ilObjectFactory::getInstanceByObjId($this->getId());
00226 }
00227 $this->setType($tmp_obj->getType());
00228
00229
00230 $class_name = $objDefinition->getClassName($this->getType());
00231 $module_name = $objDefinition->getModule($this->getType());
00232
00233 $module_dir = $module_name ? $module_name."/" : "";
00234 $class_constr = "ilObj".$class_name."GUI";
00235
00236
00237 include_once "./".$module_dir."classes/class.ilObj".$class_name."GUI.php";
00238
00239
00240 $this->gui_obj =& new $class_constr(array(),$this->getId(),$a_call_by_reference,$a_prepare_output);
00241
00242 return true;
00243 }
00244 }
00245 ?>