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