00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00031 include_once './payment/classes/class.ilPaymentTrustees.php';
00032
00033 class ilPaymentTrusteeGUI extends ilPaymentBaseGUI
00034 {
00035 var $trustee_obj = null;
00036 var $user_obj;
00037 var $ctrl;
00038
00039 function ilPaymentTrusteeGUI(&$user_obj)
00040 {
00041 global $ilCtrl;
00042
00043 $this->ctrl =& $ilCtrl;
00044
00045 $this->ilPaymentBaseGUI();
00046
00047 $this->user_obj =& $user_obj;
00048 $this->trustee_obj =& new ilPaymentTrustees($this->user_obj);
00049
00050 $this->lng->loadLanguageModule('crs');
00051 }
00055 function &executeCommand()
00056 {
00057 global $tree;
00058
00059 $cmd = $this->ctrl->getCmd();
00060 switch ($this->ctrl->getNextClass($this))
00061 {
00062 default:
00063 if(!$cmd = $this->ctrl->getCmd())
00064 {
00065 $cmd = 'showTrustees';
00066 }
00067 $this->$cmd();
00068 break;
00069 }
00070 }
00071
00072 function cancelDelete()
00073 {
00074 unset($_SESSION['paya_delete_trustee']);
00075 $this->showTrustees();
00076
00077 return true;
00078 }
00079
00080
00081 function showTrustees($a_show_delete = false)
00082 {
00083 $_SESSION['paya_delete_trustee'] = $_SESSION['paya_delete_trustee'] ? $_SESSION['paya_delete_trustee'] : array();
00084
00085 $actions = array(0 => $this->lng->txt("paya_disabled"),
00086 1 => $this->lng->txt("paya_enabled"));
00087
00088
00089 $this->showButton('searchUser',$this->lng->txt('search_user'));
00090
00091 $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_trustees.html','payment');
00092
00093 if($a_show_delete)
00094 {
00095 sendInfo($this->lng->txt('paya_sure_delete_selected_trustees'));
00096 $this->tpl->setCurrentBlock("confirm_delete");
00097 $this->tpl->setVariable("CONFIRM_FORMACTION",$this->ctrl->getFormAction($this));
00098 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
00099 $this->tpl->setVariable("TXT_CONFIRM",$this->lng->txt('delete'));
00100 $this->tpl->parseCurrentBlock();
00101 }
00102
00103 if(!count($this->trustee_obj->getTrustees()))
00104 {
00105 sendInfo($this->lng->txt('paya_no_trustees'));
00106
00107 return true;
00108 }
00109
00110 $counter = 0;
00111 $f_result = array();
00112
00113 $img_mail = "<img src=\"".ilUtil::getImagePath("icon_pencil_b.gif")."\" alt=\"".
00114 $this->lng->txt("crs_mem_send_mail").
00115 "\" title=\"".$this->lng->txt("crs_mem_send_mail")."\" border=\"0\" vspace=\"0\"/>";
00116
00117
00118 foreach($this->trustee_obj->getTrustees() as $trustee)
00119 {
00120
00121 if($tmp_obj = ilObjectFactory::getInstanceByObjId($trustee['trustee_id'],false))
00122 {
00123 $f_result[$counter][] = ilUtil::formCheckbox(in_array($trustee['trustee_id'],$_SESSION['paya_delete_trustee']) ? 1 : 0,
00124 "trustee[]",
00125 $trustee['trustee_id']);
00126 $f_result[$counter][] = $tmp_obj->getLogin();
00127 $f_result[$counter][] = $tmp_obj->getFirstname();
00128 $f_result[$counter][] = $tmp_obj->getLastname();
00129
00130 $f_result[$counter][] = ilUtil::formSelect((int) $trustee['perm_stat'],
00131 'perm_stat['.$trustee['trustee_id'].']',
00132 $actions,
00133 false,
00134 true);
00135
00136 $f_result[$counter][] = ilUtil::formSelect((int) $trustee['perm_obj'],
00137 'perm_obj['.$trustee['trustee_id'].']',
00138 $actions,
00139 false,
00140 true);
00141
00142 # $link_mail = "<a target=\"_blank\" href=\"./mail_new.php?type=new&rcp_to=".
00143 # $tmp_obj->getLogin()."\"".$img_mail."</a>";
00144 $link_mail = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"./mail_new.php?type=new&rcp_to=".
00145 $tmp_obj->getLogin()."\">".$this->lng->txt("mail")."</a></div>";
00146
00147 $f_result[$counter][] = $link_mail;
00148
00149 unset($tmp_obj);
00150 ++$counter;
00151 }
00152
00153 }
00154 return $this->__showTrusteesTable($f_result);
00155 }
00156 function deleteTrustee()
00157 {
00158 if(!is_array($_POST['trustee']))
00159 {
00160 sendInfo($this->lng->txt('crs_no_users_selected'));
00161 $this->showTrustees();
00162
00163 return true;
00164 }
00165 $_SESSION['paya_delete_trustee'] = $_POST['trustee'];
00166 $this->showTrustees(true);
00167
00168 return true;
00169 }
00170
00171 function performDeleteTrustee()
00172 {
00173 if(is_array($_SESSION['paya_delete_trustee']))
00174 {
00175 foreach($_SESSION['paya_delete_trustee'] as $id)
00176 {
00177 $this->trustee_obj->setTrusteeId($id);
00178 $this->trustee_obj->delete();
00179 }
00180 }
00181 unset($_SESSION['paya_delete_trustee']);
00182 sendInfo($this->lng->txt('paya_delete_trustee_msg'));
00183 $this->showTrustees();
00184
00185 return true;
00186 }
00187
00188 function update()
00189 {
00190 foreach($this->trustee_obj->getTrustees() as $trustee)
00191 {
00192 $this->trustee_obj->setTrusteeId($trustee['trustee_id']);
00193 $this->trustee_obj->toggleStatisticPermission($_POST['perm_stat']["$trustee[trustee_id]"]);
00194 $this->trustee_obj->toggleObjectPermission($_POST['perm_obj']["$trustee[trustee_id]"]);
00195 $this->trustee_obj->modify();
00196 }
00197 sendInfo($this->lng->txt('paya_updated_trustees'));
00198 $this->showTrustees();
00199
00200 return true;
00201 }
00202
00203 function searchUser()
00204 {
00205 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.paya_user_search.html",'payment');
00206 $this->showButton('showTrustees',$this->lng->txt('back'));
00207
00208 $this->lng->loadLanguageModule('search');
00209
00210 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
00211 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("crs_search_members"));
00212 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
00213 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["pays_search_str_trustee"] ? $_SESSION["pays_search_str_trustee"] : "");
00214 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
00215 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
00216 $this->tpl->setVariable("SEARCH","performSearch");
00217 $this->tpl->setVariable("CANCEL","showTrustees");
00218
00219 return true;
00220 }
00221
00222 function newSearch()
00223 {
00224 $_SESSION["paya_search_str"] = $_POST["search_str"];
00225 $this->performSearch();
00226 }
00227
00228 function performSearch()
00229 {
00230
00231 $_SESSION["pays_search_str_trustee"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str_trustee"];
00232
00233
00234 if(!$_POST["search_str"])
00235 {
00236 sendInfo($this->lng->txt("crs_search_enter_search_string"));
00237 # $this->searchUser();
00238 $this->showTrustees();
00239
00240 return false;
00241 }
00242 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
00243 {
00244 sendInfo($this->lng->txt("crs_no_results_found"));
00245 # $this->searchUser();
00246 $this->showTrustees();
00247
00248 return false;
00249 }
00250
00251 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_usr_selection.html",'payment');
00252 $this->showButton("searchUser",$this->lng->txt("back"));
00253
00254 $counter = 0;
00255 $f_result = array();
00256 foreach($result as $user)
00257 {
00258 if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
00259 {
00260 continue;
00261 }
00262 $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
00263 $f_result[$counter][] = $tmp_obj->getLogin();
00264 $f_result[$counter][] = $tmp_obj->getFirstname();
00265 $f_result[$counter][] = $tmp_obj->getLastname();
00266
00267 unset($tmp_obj);
00268 ++$counter;
00269 }
00270 $this->__showSearchUserTable($f_result);
00271 }
00272
00273 function addTrustee()
00274 {
00275 if(!is_array($_POST["user"]))
00276 {
00277 sendInfo($this->lng->txt("crs_no_users_selected"));
00278 $this->performSearch();
00279 # $this->showTrustees();
00280
00281 return false;
00282 }
00283 if(in_array($this->user_obj->getId(),$_POST['user']))
00284 {
00285 sendInfo($this->lng->txt('paya_not_assign_yourself'));
00286 # $this->performSearch();
00287 $this->showTrustees();
00288
00289 return false;
00290 }
00291
00292
00293
00294 $counter = 0;
00295 foreach($_POST['user'] as $user_id)
00296 {
00297 if($this->trustee_obj->isTrustee($user_id))
00298 {
00299 continue;
00300 }
00301 $this->trustee_obj->setTrusteeId($user_id);
00302 $this->trustee_obj->toggleStatisticPermission(false);
00303 $this->trustee_obj->toggleObjectPermission(true);
00304 $this->trustee_obj->add();
00305 ++$counter;
00306 }
00307
00308 if($counter)
00309 {
00310 sendInfo($this->lng->txt('paya_added_trustee'));
00311 $this->showTrustees();
00312
00313 return true;
00314 }
00315 else
00316 {
00317 sendInfo($this->lng->txt('paya_user_already_assigned'));
00318 $this->performSearch();
00319
00320 return false;
00321 }
00322
00323 }
00324 function addUser()
00325 {
00326 if(!$_POST['trustee_login'])
00327 {
00328 sendInfo($this->lng->txt('paya_enter_login'));
00329 $this->showTrustees();
00330
00331 return false;
00332 }
00333 if(!$user_id = ilObjUser::getUserIdByLogin($_POST['trustee_login']))
00334 {
00335 sendInfo($this->lng->txt('paya_no_valid_login'));
00336 $this->showTrustees();
00337
00338 return false;
00339 }
00340 if($this->trustee_obj->isTrustee($user_id))
00341 {
00342 sendInfo($this->lng->txt('paya_user_already_assigned'));
00343 $this->showTrustees();
00344
00345 return false;
00346 }
00347 if($user_id == $this->user_obj->getId())
00348 {
00349 sendInfo($this->lng->txt('paya_not_assign_yourself'));
00350 $this->showTrustees();
00351
00352 return false;
00353 }
00354
00355
00356 $this->trustee_obj->setTrusteeId($user_id);
00357 $this->trustee_obj->toggleObjectPermission(false);
00358 $this->trustee_obj->toggleStatisticPermission(true);
00359 $this->trustee_obj->add();
00360
00361 sendInfo($this->lng->txt('paya_added_trustee'));
00362 $this->showTrustees();
00363
00364 return true;
00365 }
00366
00367
00368
00369 function __search($a_search_string)
00370 {
00371 include_once("./classes/class.ilSearch.php");
00372
00373 $this->lng->loadLanguageModule("content");
00374
00375 $search =& new ilSearch($this->user_obj->getId());
00376 $search->setPerformUpdate(false);
00377 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
00378 $search->setCombination("and");
00379 $search->setSearchFor(array(0 => 'usr'));
00380 $search->setSearchType('new');
00381
00382 if($search->validate($message))
00383 {
00384 $search->performSearch();
00385 }
00386 else
00387 {
00388 sendInfo($message,true);
00389 $this->ctrl->redirect($this,"searchUser");
00390 }
00391 return $search->getResultByType('usr');
00392 }
00393 function __showSearchUserTable($a_result_set)
00394 {
00395 $tbl =& $this->initTableGUI();
00396 $tpl =& $tbl->getTemplateObject();
00397
00398
00399
00400 $tpl->setCurrentBlock("tbl_form_header");
00401 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00402 $tpl->parseCurrentBlock();
00403
00404 $tpl->setCurrentBlock("tbl_action_btn");
00405 $tpl->setVariable("BTN_NAME","addTrustee");
00406 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
00407 $tpl->parseCurrentBlock();
00408
00409 $tpl->setCurrentBlock("tbl_action_btn");
00410 $tpl->setVariable("BTN_NAME","showTrustees");
00411 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
00412 $tpl->parseCurrentBlock();
00413
00414 $tpl->setCurrentBlock("tbl_action_row");
00415 $tpl->setVariable("COLUMN_COUNTS",5);
00416 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00417 $tpl->parseCurrentBlock();
00418
00419 $tbl->setTitle($this->lng->txt("paya_trustee_table"),"icon_usr.gif",$this->lng->txt("crs_header_edit_members"));
00420 $tbl->setHeaderNames(array("",
00421 $this->lng->txt("login"),
00422 $this->lng->txt("firstname"),
00423 $this->lng->txt("lastname")));
00424 $tbl->setHeaderVars(array("",
00425 "login",
00426 "firstname",
00427 "lastname"),
00428 array("cmd" => 'performSearch',
00429 "cmdClass" => "ilpaymenttrusteegui",
00430 "cmdNode" => $_GET["cmdNode"]));
00431
00432 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
00433
00434 $this->setTableGUIBasicData($tbl,$a_result_set);
00435 $tbl->render();
00436
00437 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
00438
00439 return true;
00440 }
00441
00442 function __showTrusteesTable($a_result_set)
00443 {
00444 $tbl =& $this->initTableGUI();
00445 $tpl =& $tbl->getTemplateObject();
00446
00447
00448 $tpl->setCurrentBlock("tbl_form_header");
00449
00450 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00451 $tpl->parseCurrentBlock();
00452
00453 $tpl->setCurrentBlock("tbl_action_row");
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 $tpl->setCurrentBlock("input_text");
00465 $tpl->setVariable("PB_TXT_NAME",'search_str');
00466 $tpl->setVariable("PB_TXT_VALUE",$_SESSION["paya_search_str"]);
00467 $tpl->parseCurrentBlock();
00468
00469 $tpl->setCurrentBlock("plain_button");
00470 $tpl->setVariable("PBTN_NAME","newSearch");
00471 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("crs_add_member"));
00472 $tpl->parseCurrentBlock();
00473
00474 $tpl->setCurrentBlock("plain_button");
00475 $tpl->setVariable("PBTN_NAME","update");
00476 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("apply"));
00477 $tpl->parseCurrentBlock();
00478
00479 $tpl->setCurrentBlock("plain_buttons");
00480 $tpl->parseCurrentBlock();
00481
00482 $tpl->setVariable("COLUMN_COUNTS",7);
00483 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00484
00485 $tpl->setCurrentBlock("tbl_action_button");
00486 $tpl->setVariable("BTN_NAME","deleteTrustee");
00487 $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
00488 $tpl->parseCurrentBlock();
00489 $tpl->setCurrentBlock("tbl_action_row");
00490 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00491 $tpl->parseCurrentBlock();
00492
00493 $tbl->setTitle($this->lng->txt("paya_trustee_table"),"icon_usr.gif",$this->lng->txt("paya_trustee_table"));
00494 $tbl->setHeaderNames(array('',
00495 $this->lng->txt("login"),
00496 $this->lng->txt("firstname"),
00497 $this->lng->txt("lastname"),
00498 $this->lng->txt("paya_perm_stat"),
00499 $this->lng->txt("paya_perm_obj"),
00500 ''));
00501 $tbl->setHeaderVars(array("",
00502 "login",
00503 "firstname",
00504 "lastname",
00505 "perm_stat",
00506 "perm_obj",
00507 "options"),
00508 array("cmd" => "showTrustees",
00509 "cmdClass" => "ilpaymenttrusteegui",
00510 "cmdNode" => $_GET["cmdNode"]));
00511 $tbl->setColumnWidth(array("4%","15%","15%","15%","20%","20%","15%"));
00512
00513
00514 $this->setTableGUIBasicData($tbl,$a_result_set);
00515 $tbl->render();
00516
00517 $this->tpl->setVariable("TRUSTEE_TABLE",$tbl->tpl->get());
00518
00519 return true;
00520 }
00521
00522 }
00523 ?>