00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00032 class ilRegisterGUI
00033 {
00034 var $lng;
00035 var $ilias;
00036 var $tpl;
00037 var $tree;
00038 var $objDefinition;
00039 var $ctrl;
00040 var $cmd;
00041 var $ilErr;
00042 var $object;
00043
00048 function ilRegisterGUI()
00049 {
00050 global $lng, $ilias, $tpl, $tree, $objDefinition, $ilCtrl, $ilErr;
00051
00052 $this->lng =& $lng;
00053 $this->ilias =& $ilias;
00054 $this->tpl =& $tpl;
00055 $this->tree =& $tree;
00056 $this->objDefinition =& $objDefinition;
00057 $this->ilErr =& $ilErr;
00058
00059 $this->ctrl =& $ilCtrl;
00060 $this->ctrl->saveParameter($this,array("ref_id"));
00061 $this->ctrl->setParameter($this,"user_id",$this->ilias->account->getId());
00062
00063
00064 $this->object =& $this->ilias->obj_factory->getInstanceByRefId($_GET["ref_id"]);
00065 }
00066
00070 function &executeCommand()
00071 {
00072 $cmd = $this->ctrl->getCmd();
00073
00074 if (empty($cmd))
00075 {
00076 $cmd = "cancel";
00077 }
00078
00079 $this->cmd = $cmd;
00080 $this->$cmd();
00081 }
00082
00083 function showRegistrationForm()
00084 {
00085 global $rbacsystem, $ilias, $lng;
00086
00087 $owner = new ilObjUser($this->object->getOwner());
00088
00089 switch ($this->object->getRegistrationFlag())
00090 {
00091 case 0:
00092 $stat = $this->lng->txt("group_no_registration");
00093 $msg = $this->lng->txt("group_no_registration_msg");
00094 $readonly ="readonly";
00095 $subject ="";
00096 $cmd_submit = "subscribe";
00097 $txt_submit = $this->lng->txt("grp_register");
00098 break;
00099
00100 case 1:
00101 $stat = $this->lng->txt("group_req_registration");
00102 $msg = $this->lng->txt("group_req_registration_msg");
00103 $cmd_submit = "apply";
00104 $txt_submit = $this->lng->txt("grp_register");
00105 $txt_subject =$this->lng->txt("subject").":";
00106 $textfield = "<textarea name=\"subject\" value=\"{SUBJECT}\" cols=\"50\" rows=\"5\" size=\"255\"></textarea>";
00107 break;
00108
00109 case 2:
00110 if ($this->object->registrationPossible() == true)
00111 {
00112 $stat = $this->lng->txt("group_req_password");
00113 $msg = $this->lng->txt("group_password_registration_msg");
00114 $txt_subject =$this->lng->txt("password").":";
00115 $txt_submit = $this->lng->txt("grp_register");
00116 $textfield = "<input name=\"subject\" value=\"{SUBJECT}\" type=\"password\" size=\"40\" maxlength=\"70\" style=\"width:300px;\"/>";
00117 $cmd_submit = "apply";
00118 }
00119 else
00120 {
00121 $no_cancel = true;
00122 $msg = $this->lng->txt("group_password_registration_expired_msg");
00123 $msg_send = "mail_new.php?mobj_id=3&type=new&rcp_to=root";
00124 $cmd_submit = "cancel";
00125 $txt_submit = $this->lng->txt("grp_back");
00126 $readonly = "readonly";
00127 $stat = $this->lng->txt("group_registration_expired");
00128 sendInfo($this->lng->txt("registration_expired"));
00129 }
00130 break;
00131 }
00132
00133 if ($no_cancel !== true)
00134 {
00135 $this->tpl->setCurrentBlock("btn_cancel");
00136 $this->tpl->setVariable("CMD_CANCEL","cancel");
00137 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
00138 $this->tpl->parseCurrentBlock();
00139 }
00140
00141 if (!$rbacsystem->checkAccess("join", $_GET["ref_id"]))
00142 {
00143 $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
00144 return;
00145 }
00146
00147 $this->tpl->addBlockFile("ADM_CONTENT", "tbldesc", "tpl.grp_accessdenied.html");
00148 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("group_access_denied"));
00149 $this->tpl->setVariable("TXT_MESSAGE",$msg);
00150 $this->tpl->setVariable("TXT_GRP_NAME", $this->lng->txt("group_name").":");
00151 $this->tpl->setVariable("GRP_NAME",$this->object->getTitle());
00152 $this->tpl->setVariable("TXT_GRP_DESC",$this->lng->txt("group_desc").":");
00153 $this->tpl->setVariable("GRP_DESC",$this->object->getDescription());
00154 $this->tpl->setVariable("TXT_GRP_OWNER",$this->lng->txt("owner").":");
00155 $this->tpl->setVariable("GRP_OWNER",$owner->getLogin());
00156 $this->tpl->setVariable("TXT_GRP_STATUS",$this->lng->txt("group_status").":");
00157 $this->tpl->setVariable("GRP_STATUS", $stat);
00158 $this->tpl->setVariable("TXT_SUBJECT",$txt_subject);
00159 $this->tpl->setVariable("SUBJECT",$textfield);
00160 $this->tpl->setVariable("TXT_SUBMIT",$txt_submit);
00161 $this->tpl->setVariable("CMD_SUBMIT",$cmd_submit);
00162 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00163 $this->tpl->parseCurrentBlock();
00164 }
00165
00166 function cancel()
00167 {
00168 sendInfo($this->lng->txt("action_aborted"),true);
00169 $this->ctrl->setParameterByClass("ilRepositoryGUI","ref_id",$this->getReturnRefId());
00170 $this->ctrl->redirectByClass("ilRepositoryGUI","ShowList");
00171 }
00172
00173 function subscribe()
00174 {
00175 if (!$this->object->addMember($this->ilias->account->getId(), $this->object->getDefaultMemberRole()))
00176 {
00177 $this->ilErr->raiseError($this->lng->txt("err_unknown_error"),$this->ilErr->MESSAGE);
00178 }
00179
00180 sendInfo($this->lng->txt("grp_registration_completed"),true);
00181 $this->ctrl->returnToParent($this);
00182 }
00183
00184 function apply()
00185 {
00186 switch ($this->object->getRegistrationFlag())
00187 {
00188
00189 case 1:
00190 $q = "SELECT * FROM grp_registration WHERE grp_id=".$this->object->getId()." AND user_id=".$this->ilias->account->getId();
00191 $res = $this->ilias->db->query($q);
00192
00193 if ($res->numRows() > 0)
00194 {
00195 $this->ilErr->raiseError($this->lng->txt("grp_already_applied"),$this->ilErr->MESSAGE);
00196 }
00197
00198 $q = "INSERT INTO grp_registration VALUES (".$this->object->getId().",".$this->ilias->account->getId().",'".$_POST["subject"]."','".date("Y-m-d H:i:s")."')";
00199 $this->ilias->db->query($q);
00200
00201 sendInfo($this->lng->txt("application_completed"),true);
00202 $this->ctrl->setParameterByClass("ilRepositoryGUI","ref_id",$this->getReturnRefId());
00203 $this->ctrl->redirectByClass("ilRepositoryGUI","ShowList");
00204 break;
00205
00206
00207 case 2:
00208 if (strcmp($this->object->getPassword(),$_POST["subject"]) != 0 && $this->object->registrationPossible() == true)
00209 {
00210 $this->ilErr->raiseError($this->lng->txt("err_wrong_password"),$this->ilErr->MESSAGE);
00211 }
00212
00213 if (strcmp($this->object->getPassword(),$_POST["subject"]) == 0 && $this->object->registrationPossible() == true)
00214 {
00215 $this->object->addMember($this->ilias->account->getId(),$this->object->getDefaultMemberRole());
00216 sendInfo($this->lng->txt("grp_registration_completed"),true);
00217 $this->ctrl->returnToParent($this);
00218 }
00219
00220 $this->ilErr->raiseError($this->lng->txt("registration_not_possible"),$this->ilErr->MESSAGE);
00221 break;
00222
00223 default:
00224 $this->ilErr->raiseError($this->lng->txt("err_unknown_error"),$this->ilErr->MESSAGE);
00225 break;
00226 }
00227 }
00228
00229 function getReturnRefId()
00230 {
00231 if ($_SESSION["il_rep_ref_id"] == $this->object->getRefId())
00232 {
00233 return $this->tree->getParentId($this->object->getRefId());
00234 }
00235 else
00236 {
00237 return $_SESSION["il_rep_ref_id"];
00238 }
00239 }
00240 }
00241 ?>