Ejemplo n.º 1
0
 /**
  * this function manage the entire profile, identify the action to perform and do the right sequence of action
  * @return string the html to display
  */
 function performAction($viewer = false, $start_action = false)
 {
     $this->setViewer($viewer);
     if ($start_action === false) {
         $start_action = 'profileview';
     }
     $ap = Get::req($this->_varname_action, DOTY_MIXED, $start_action);
     if (isset($_POST['undo'])) {
         $ap = 'profileview';
     }
     switch ($ap) {
         case "goprofile":
             $ext_prof = new UserProfile(Get::req('id_user', DOTY_INT, 0), false);
             $ext_prof->init($this->_module_name, $this->_platform, $this->_std_query, $this->_varname_action);
             return $ext_prof->getProfile();
             break;
             // display the mod info gui -------------------------------
         // display the mod info gui -------------------------------
         case "mod_profile":
             return $this->getModUser();
             break;
         case "mod_password":
             return $this->_up_viewer->getUserPwdModUi();
             break;
         case "mod_policy":
             return $this->_up_viewer->modUserPolicyGui();
             break;
             // save modified info of the user -------------------------
         // save modified info of the user -------------------------
         case "save_policy":
             if ($this->_up_data_man->setFieldAccessList($this->_id_user, $this->_up_viewer->getFilledPolicy())) {
                 // all ok --------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 return getResultUi($this->_lang->def('_OPERATION_SUCCESSFULPOLICY')) . $this->getProfile();
             } else {
                 // some error saving ---------------------------
                 return getErrorUi($this->_lang->def('_FAILSAVEPOLICY')) . $this->_up_viewer->modUserPolicyGui();
             }
             break;
             // save modified info of the user -------------------------
         // save modified info of the user -------------------------
         case "saveinfo":
             if (!$this->checkUserInfo()) {
                 // some error in data filling ------------------
                 return getErrorUi($this->_last_error) . $this->getModUser();
             }
             if ($this->saveUserInfo()) {
                 // all ok --------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 if (isset($_GET['modname']) && $_GET['modname'] == 'reservation') {
                     require_once $GLOBALS['where_lms'] . '/lib/lib.reservation.php';
                     $id_event = Get::req('id_event', DOTY_INT, 0);
                     $man_res = new Man_Reservation();
                     $result = $man_res->addSubscription(getLogUserId(), $id_event);
                     Util::jump_to('index.php?modname=reservation&op=reservation');
                 } else {
                     return getResultUi($this->_lang->def('_OPERATION_SUCCESSFULPROFILE')) . $this->getProfile();
                 }
             } else {
                 // some error saving ---------------------------
                 return getErrorUi($this->_lang->def('_OPERATION_FAILURE')) . $this->getModUser();
             }
             break;
             // save password -----------------------------------------
         // save password -----------------------------------------
         case "savepwd":
             $re = $this->_up_viewer->checkUserPwd();
             if ($re !== true) {
                 // some error in data filling --------------------
                 return getErrorUi($re) . $this->_up_viewer->getUserPwdModUi();
             }
             if ($this->saveUserPwd()) {
                 // all ok ----------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 $out = getResultUi($this->_lang->def('_OPERATION_SUCCESSFULPWD'));
                 if (Get::sett('profile_only_pwd') == 'on') {
                     // maybe is better if we display only the confirmation message if all is ok, but if you
                     // want something else add the code here
                 } else {
                     $out .= $this->getProfile();
                 }
                 return $out;
             } else {
                 // some error saving ----------------------------
                 return getErrorUi($this->_lang->def('_OPERATION_FAILURE')) . $this->_up_viewer->getUserPwdModUi();
             }
             break;
         case "uploadavatar":
             return $this->_up_viewer->modAvatarGui();
             break;
         case "saveavatar":
             if ($this->saveUserAvatar()) {
                 // all ok --------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 return getResultUi($this->_lang->def('_OPERATION_SUCCESSFULAVATAR')) . $this->getProfile();
             } else {
                 // some error saving ---------------------------
                 return getErrorUi($this->_lang->def('_OPERATION_FAILURE')) . $this->_up_viewer->modAvatarGui();
             }
             break;
             // teacher curriculum
         // teacher curriculum
         case "del_teach_curric":
             return $this->_up_viewer->delTeacherCurriculumGui();
             break;
         case "mod_teach_curric":
             return $this->_up_viewer->modTeacherCurriculumGui();
             break;
         case "save_teach_curric":
             if ($this->_up_data_man->saveTeacherCurriculumAndPublication($this->_id_user, $this->_up_viewer->getFilledCurriculum(), false)) {
                 // all ok --------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 return getResultUi($this->_lang->def('_OPERATION_SUCCESSFULCURRICULUM')) . $this->getProfile();
             } else {
                 // some error saving ---------------------------
                 return getErrorUi($this->_lang->def('_OPERATION_FAILURE')) . $this->_up_viewer->modTeacherCurriculumGui();
             }
             break;
         case "mod_teach_publ":
             return $this->_up_viewer->modTeacherPublicationsGui();
             break;
         case "save_teach_publ":
             if ($this->_up_data_man->saveTeacherCurriculumAndPublication($this->_id_user, false, $this->_up_viewer->getFilledPublications())) {
                 // all ok --------------------------------------
                 $this->_up_viewer->unloadUserData();
                 if ($this->_end_url !== false) {
                     Util::jump_to($this->_end_url);
                 }
                 return getResultUi($this->_lang->def('_OPERATION_SUCCESSFULPUBLICATIONS')) . $this->getProfile();
             } else {
                 // some error saving ---------------------------
                 return getErrorUi($this->_lang->def('_FAILSAVEPUBLICATIONS')) . $this->_up_viewer->modTeacherPublicationsGui();
             }
             break;
             // display the profile ------------------------------------
         // display the profile ------------------------------------
         case "view_files":
             $this->_id_user = Get::req('id_user', DOTY_INT, getLogUserId());
             return $this->_up_viewer->getViewUserFiles();
             break;
         case "file_details":
             $this->_id_user = Get::req('id_user', DOTY_INT, getLogUserId());
             return $this->_up_viewer->getViewUserFileDetail();
             break;
         case "profileview":
         default:
             return $this->getProfile();
             break;
     }
 }
Ejemplo n.º 2
0
 function sendRegistration()
 {
     checkPerm('view');
     require_once _base_ . '/lib/lib.userselector.php';
     $id_course = importVar('id_course', true, 0);
     $id_event = importVar('id_event', true, 0);
     $lang =& DoceboLanguage::CreateInstance('reservation');
     $out =& $GLOBALS['page'];
     $man_res = new Man_Reservation();
     $id_category = $man_res->getEventCategory($id_event);
     $user_select = new UserSelector();
     $user_subscribed = array();
     $user_subscribed = $man_res->getSubscribedUserIdst($id_event);
     $user_selected = array();
     $user_selected = $user_select->getSelection($_POST);
     $wrong_result = false;
     $user_deleted = array_diff($user_subscribed, $user_selected);
     foreach ($user_deleted as $del) {
         $result = $man_res->delSubscription($del, $id_event);
         if (!$result) {
             $wrong_result = true;
         }
     }
     foreach ($user_selected as $user) {
         if ($man_res->controlMaxSubscriptionForCategory($id_category, $user)) {
             $result = $man_res->addSubscription($user, $id_event);
             if (!$result) {
                 $wrong_result = true;
             }
         } else {
             $wrong_result = true;
         }
     }
     if ($wrong_result) {
         Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user&error=insert');
     }
     Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user');
 }