• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/classes/class.ilPaymentTrusteeGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 */
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                         ilUtil::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                         ilUtil::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                         // GET USER OBJ
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                                 $f_result[$counter][]   = ilUtil::formSelect((int) $trustee['perm_coupons'],
00143                                                                                                                          'perm_coupons['.$trustee['trustee_id'].']',
00144                                                                                                                          $actions,
00145                                                                                                                          false,
00146                                                                                                                          true);
00147 
00148 #                               $link_mail = "<a target=\"_blank\" href=\"./ilias.php?baseClass=ilMailGUI&type=new&rcp_to=".
00149 #                                       $tmp_obj->getLogin()."\"".$img_mail."</a>";
00150                                 $link_mail = "<div class=\"il_ContainerItemCommands\"><a class=\"il_ContainerItemCommand\" href=\"./ilias.php?baseClass=ilMailGUI&type=new&rcp_to=".
00151                                         $tmp_obj->getLogin()."\">".$this->lng->txt("mail")."</a></div>";
00152                                 
00153                                 $f_result[$counter][]   = $link_mail;
00154 
00155                                 unset($tmp_obj);
00156                                 ++$counter;
00157                         }
00158 
00159                 }
00160                 return $this->__showTrusteesTable($f_result);
00161         }
00162         function deleteTrustee()
00163         {
00164                 if(!is_array($_POST['trustee']))
00165                 {
00166                         ilUtil::sendInfo($this->lng->txt('crs_no_users_selected'));
00167                         $this->showTrustees();
00168 
00169                         return true;
00170                 }
00171                 $_SESSION['paya_delete_trustee'] = $_POST['trustee'];
00172                 $this->showTrustees(true);
00173                 
00174                 return true;
00175         }
00176 
00177         function performDeleteTrustee()
00178         {
00179                 if(is_array($_SESSION['paya_delete_trustee']))
00180                 {
00181                         foreach($_SESSION['paya_delete_trustee'] as $id)
00182                         {
00183                                 $this->trustee_obj->setTrusteeId($id);
00184                                 $this->trustee_obj->delete();
00185                         }
00186                 }
00187                 unset($_SESSION['paya_delete_trustee']);
00188                 ilUtil::sendInfo($this->lng->txt('paya_delete_trustee_msg'));
00189                 $this->showTrustees();
00190 
00191                 return true;
00192         }
00193 
00194         function update()
00195         {
00196                 foreach($this->trustee_obj->getTrustees() as $trustee)
00197                 {
00198                         $this->trustee_obj->setTrusteeId($trustee['trustee_id']);
00199                         $this->trustee_obj->toggleStatisticPermission($_POST['perm_stat']["$trustee[trustee_id]"]);
00200                         $this->trustee_obj->toggleObjectPermission($_POST['perm_obj']["$trustee[trustee_id]"]);
00201                         $this->trustee_obj->toggleCouponsPermission($_POST['perm_coupons']["$trustee[trustee_id]"]);                    
00202                         $this->trustee_obj->modify();
00203                 }
00204                 ilUtil::sendInfo($this->lng->txt('paya_updated_trustees'));
00205                 $this->showTrustees();
00206 
00207                 return true;
00208         }
00209 
00210         function searchUser()
00211         {
00212                 $this->tpl->addBlockFile("ADM_CONTENT","adm_content","tpl.paya_user_search.html",'payment');
00213                 $this->showButton('showTrustees',$this->lng->txt('back'));
00214 
00215                 $this->lng->loadLanguageModule('search');
00216 
00217                 $this->tpl->setVariable("F_ACTION",$this->ctrl->getFormAction($this));
00218                 $this->tpl->setVariable("SEARCH_ASSIGN_USR",$this->lng->txt("crs_search_members"));
00219                 $this->tpl->setVariable("SEARCH_SEARCH_TERM",$this->lng->txt("search_search_term"));
00220                 $this->tpl->setVariable("SEARCH_VALUE",$_SESSION["pays_search_str_trustee"] ? $_SESSION["pays_search_str_trustee"] : "");
00221                 $this->tpl->setVariable("BTN2_VALUE",$this->lng->txt("cancel"));
00222                 $this->tpl->setVariable("BTN1_VALUE",$this->lng->txt("search"));
00223                 $this->tpl->setVariable("SEARCH","performSearch");
00224                 $this->tpl->setVariable("CANCEL","showTrustees");
00225 
00226                 return true;
00227         }
00228 
00229         function newSearch()
00230         {
00231                 $_SESSION["paya_search_str"] = $_POST["search_str"];
00232                 $this->performSearch();
00233         }
00234 
00235         function performSearch()
00236         {
00237                 // SAVE it to allow sort in tables
00238                 $_SESSION["pays_search_str_trustee"] = $_POST["search_str"] = $_POST["search_str"] ? $_POST["search_str"] : $_SESSION["pays_search_str_trustee"];
00239 
00240 
00241                 if(!$_POST["search_str"])
00242                 {
00243                         ilUtil::sendInfo($this->lng->txt("crs_search_enter_search_string"));
00244 #                       $this->searchUser();
00245                         $this->showTrustees();
00246 
00247                         return false;
00248                 }
00249                 if(!count($result = $this->__search(ilUtil::stripSlashes($_POST["search_str"]))))
00250                 {
00251                         ilUtil::sendInfo($this->lng->txt("crs_no_results_found"));
00252 #                       $this->searchUser();
00253                         $this->showTrustees();
00254 
00255                         return false;
00256                 }
00257 
00258                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paya_usr_selection.html",'payment');
00259                 $this->showButton("searchUser",$this->lng->txt("back"));
00260                 
00261                 $counter = 0;
00262                 $f_result = array();
00263                 foreach($result as $user)
00264                 {
00265                         if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user["id"],false))
00266                         {
00267                                 continue;
00268                         }
00269                         $f_result[$counter][] = ilUtil::formCheckbox(0,"user[]",$user["id"]);
00270                         $f_result[$counter][] = $tmp_obj->getLogin();
00271                         $f_result[$counter][] = $tmp_obj->getFirstname();
00272                         $f_result[$counter][] = $tmp_obj->getLastname();
00273                         
00274                         unset($tmp_obj);
00275                         ++$counter;
00276                 }
00277                 $this->__showSearchUserTable($f_result);
00278         }
00279 
00280         function addTrustee()
00281         {
00282                 if(!is_array($_POST["user"]))
00283                 {
00284                         ilUtil::sendInfo($this->lng->txt("crs_no_users_selected"));
00285                         $this->performSearch();
00286 #                       $this->showTrustees();
00287 
00288                         return false;
00289                 }
00290                 if(in_array($this->user_obj->getId(),$_POST['user']))
00291                 {
00292                         ilUtil::sendInfo($this->lng->txt('paya_not_assign_yourself'));
00293 #                       $this->performSearch();
00294                         $this->showTrustees();
00295 
00296                         return false;
00297                 }
00298 
00299 
00300                 // add them
00301                 $counter = 0;
00302                 foreach($_POST['user'] as $user_id)
00303                 {
00304                         if($this->trustee_obj->isTrustee($user_id))
00305                         {
00306                                 continue;
00307                         }
00308                         $this->trustee_obj->setTrusteeId($user_id);
00309                         $this->trustee_obj->toggleStatisticPermission(false);
00310                         $this->trustee_obj->toggleObjectPermission(true);
00311                         $this->trustee_obj->toggleCouponsPermission(true);
00312                         $this->trustee_obj->add();
00313                         ++$counter;
00314                 }
00315 
00316                 if($counter)
00317                 {
00318                         ilUtil::sendInfo($this->lng->txt('paya_added_trustee'));
00319                         $this->showTrustees();
00320 
00321                         return true;
00322                 }
00323                 else
00324                 {
00325                         ilUtil::sendInfo($this->lng->txt('paya_user_already_assigned'));
00326                         $this->performSearch();
00327 
00328                         return false;
00329                 }
00330 
00331         }
00332         function addUser()
00333         {
00334                 if(!$_POST['trustee_login'])
00335                 {
00336                         ilUtil::sendInfo($this->lng->txt('paya_enter_login'));
00337                         $this->showTrustees();
00338                         
00339                         return false;
00340                 }
00341                 if(!$user_id = ilObjUser::getUserIdByLogin($_POST['trustee_login']))
00342                 {
00343                         ilUtil::sendInfo($this->lng->txt('paya_no_valid_login'));
00344                         $this->showTrustees();
00345                         
00346                         return false;
00347                 }
00348                 if($this->trustee_obj->isTrustee($user_id))
00349                 {
00350                         ilUtil::sendInfo($this->lng->txt('paya_user_already_assigned'));
00351                         $this->showTrustees();
00352                         
00353                         return false;
00354                 }
00355                 if($user_id == $this->user_obj->getId())
00356                 {
00357                         ilUtil::sendInfo($this->lng->txt('paya_not_assign_yourself'));
00358                         $this->showTrustees();
00359 
00360                         return false;
00361                 }
00362                 
00363                 // checks passed => add trustee
00364                 $this->trustee_obj->setTrusteeId($user_id);
00365                 $this->trustee_obj->toggleObjectPermission(false);
00366                 $this->trustee_obj->toggleStatisticPermission(true);
00367                 $this->trustee_obj->toggleCouponsPermission(true);
00368                 $this->trustee_obj->add();
00369 
00370                 ilUtil::sendInfo($this->lng->txt('paya_added_trustee'));
00371                 $this->showTrustees();
00372 
00373                 return true;
00374         }
00375         
00376 
00377         // PRIVATE
00378         function __search($a_search_string)
00379         {
00380                 include_once("./classes/class.ilSearch.php");
00381 
00382                 $this->lng->loadLanguageModule("content");
00383 
00384                 $search =& new ilSearch($this->user_obj->getId());
00385                 $search->setPerformUpdate(false);
00386                 $search->setSearchString(ilUtil::stripSlashes($a_search_string));
00387                 $search->setCombination("and");
00388                 $search->setSearchFor(array(0 => 'usr'));
00389                 $search->setSearchType('new');
00390 
00391                 if($search->validate($message))
00392                 {
00393                         $search->performSearch();
00394                 }
00395                 else
00396                 {
00397                         ilUtil::sendInfo($message,true);
00398                         $this->ctrl->redirect($this,"searchUser");
00399                 }
00400                 return $search->getResultByType('usr');
00401         }
00402         function __showSearchUserTable($a_result_set)
00403         {
00404                 $tbl =& $this->initTableGUI();
00405                 $tpl =& $tbl->getTemplateObject();
00406 
00407 
00408                 // SET FORMACTION
00409                 $tpl->setCurrentBlock("tbl_form_header");
00410                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00411                 $tpl->parseCurrentBlock();
00412 
00413                 $tpl->setCurrentBlock("tbl_action_btn");
00414                 $tpl->setVariable("BTN_NAME","addTrustee");
00415                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("add"));
00416                 $tpl->parseCurrentBlock();
00417 
00418                 $tpl->setCurrentBlock("tbl_action_btn");
00419                 $tpl->setVariable("BTN_NAME","showTrustees");
00420                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
00421                 $tpl->parseCurrentBlock();
00422 
00423                 $tpl->setCurrentBlock("tbl_action_row");
00424                 $tpl->setVariable("COLUMN_COUNTS",5);
00425                 $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00426                 $tpl->parseCurrentBlock();
00427 
00428                 $tbl->setTitle($this->lng->txt("paya_trustee_table"),"icon_usr.gif",$this->lng->txt("crs_header_edit_members"));
00429                 $tbl->setHeaderNames(array("",
00430                                                                    $this->lng->txt("login"),
00431                                                                    $this->lng->txt("firstname"),
00432                                                                    $this->lng->txt("lastname")));
00433                 $tbl->setHeaderVars(array("",
00434                                                                   "login",
00435                                                                   "firstname",
00436                                                                   "lastname"),
00437                                                         array("cmd" => 'performSearch',
00438                                                                   "cmdClass" => "ilpaymenttrusteegui",
00439                                                                   "cmdNode" => $_GET["cmdNode"]));
00440 
00441                 $tbl->setColumnWidth(array("3%","32%","32%","32%"));
00442 
00443                 $this->setTableGUIBasicData($tbl,$a_result_set);
00444                 $tbl->render();
00445                 
00446                 $this->tpl->setVariable("SEARCH_RESULT_TABLE",$tbl->tpl->get());
00447 
00448                 return true;
00449         }
00450         
00451         function __showTrusteesTable($a_result_set)
00452         {
00453                 $tbl =& $this->initTableGUI();
00454                 $tpl =& $tbl->getTemplateObject();
00455 
00456                 // SET FORMAACTION
00457                 $tpl->setCurrentBlock("tbl_form_header");
00458 
00459                 $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00460                 $tpl->parseCurrentBlock();
00461 
00462                 $tpl->setCurrentBlock("tbl_action_row");
00463 
00464 /*              $tpl->setCurrentBlock("input_text");
00465                 $tpl->setVariable("PB_TXT_NAME",'trustee_login');
00466                 $tpl->parseCurrentBlock();
00467 
00468                 $tpl->setCurrentBlock("plain_button");
00469                 $tpl->setVariable("PBTN_NAME","addUser");
00470                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("crs_add_member"));
00471                 $tpl->parseCurrentBlock();*/
00472 
00473                 $tpl->setCurrentBlock("input_text");
00474                 $tpl->setVariable("PB_TXT_NAME",'search_str');
00475                 $tpl->setVariable("PB_TXT_VALUE",$_SESSION["paya_search_str"]);
00476                 $tpl->parseCurrentBlock();
00477 
00478                 $tpl->setCurrentBlock("plain_button");
00479                 $tpl->setVariable("PBTN_NAME","newSearch");
00480                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("crs_add_member"));
00481                 $tpl->parseCurrentBlock();
00482 
00483                 $tpl->setCurrentBlock("plain_button");
00484                 $tpl->setVariable("PBTN_NAME","update");
00485                 $tpl->setVariable("PBTN_VALUE",$this->lng->txt("apply"));
00486                 $tpl->parseCurrentBlock();
00487 
00488                 $tpl->setCurrentBlock("plain_buttons");
00489                 $tpl->parseCurrentBlock();
00490 
00491                 $tpl->setVariable("COLUMN_COUNTS",8);
00492                 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00493 
00494                 $tpl->setCurrentBlock("tbl_action_button");
00495                 $tpl->setVariable("BTN_NAME","deleteTrustee");
00496                 $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
00497                 $tpl->parseCurrentBlock();
00498                 $tpl->setCurrentBlock("tbl_action_row");
00499                 $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
00500                 $tpl->parseCurrentBlock();
00501 
00502                 $tbl->setTitle($this->lng->txt("paya_trustee_table"),"icon_usr.gif",$this->lng->txt("paya_trustee_table"));
00503                 $tbl->setHeaderNames(array('',
00504                                                                    $this->lng->txt("login"),
00505                                                                    $this->lng->txt("firstname"),
00506                                                                    $this->lng->txt("lastname"),
00507                                                                    $this->lng->txt("paya_perm_stat"),
00508                                                                    $this->lng->txt("paya_perm_obj"),
00509                                                                    $this->lng->txt("paya_perm_coupons"),
00510                                                                    ''));
00511                 $tbl->setHeaderVars(array("",
00512                                                                   "login",
00513                                                                   "firstname",
00514                                                                   "lastname",
00515                                                                   "perm_stat",
00516                                                                   "perm_obj",
00517                                                                   "perm_coupons",
00518                                                                   "options"),
00519                                                         array("cmd" => "showTrustees",
00520                                                                   "cmdClass" => "ilpaymenttrusteegui",
00521                                                                   "cmdNode" => $_GET["cmdNode"]));
00522                 $tbl->setColumnWidth(array("4%","15%","15%","15%","15%","15%","15%","15%"));
00523 
00524 
00525                 $this->setTableGUIBasicData($tbl,$a_result_set);
00526                 $tbl->render();
00527 
00528                 $this->tpl->setVariable("TRUSTEE_TABLE",$tbl->tpl->get());
00529 
00530                 return true;
00531         }
00532 
00533 }
00534 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1