Example #1
0
 /** Function to save the user information into the database
  * @param $module -- module name:: Type varchar
  *
  */
 function save($module_name)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     //Event triggering code
     require_once "include/events/include.inc";
     //In Bulk mode stop triggering events
     if (!self::isBulkSaveMode()) {
         $em = new VTEventsManager($adb);
         // Initialize Event trigger cache
         $em->initTriggerCache();
         $entityData = VTEntityData::fromCRMEntity($this);
         $em->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData);
         $em->triggerEvent("vtiger.entity.beforesave", $entityData);
         $em->triggerEvent("vtiger.entity.beforesave.final", $entityData);
     }
     if ($this->mode != 'edit') {
         $sql = 'SELECT id FROM vtiger_users WHERE user_name = ? OR email1 = ?';
         $result = $adb->pquery($sql, array($this->column_fields['user_name'], $this->column_fields['email1']));
         if ($adb->num_rows($result) > 0) {
             Vtiger_Functions::throwNewException('LBL_USER_EXISTS');
             throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_USER_EXISTS'));
             return false;
         }
     } else {
         $query = 'SELECT `roleid` FROM `vtiger_user2role` WHERE `userid` = ? LIMIT 1;';
         $oldRoleResult = $adb->pquery($query, [$this->id]);
         $oldRole = $adb->query_result($oldRoleResult, 0, 'roleid');
         if ($oldRole != $this->column_fields['roleid']) {
             $query = 'DELETE FROM `vtiger_module_dashboard_widgets` WHERE `userid` = ?;';
             $adb->pquery($query, [$this->id]);
         }
     }
     //Save entity being called with the modulename as parameter
     $this->saveentity($module_name);
     if ($em) {
         //Event triggering code
         $em->triggerEvent("vtiger.entity.aftersave", $entityData);
         $em->triggerEvent("vtiger.entity.aftersave.final", $entityData);
         //Event triggering code ends
     }
     // Added for Reminder Popup support
     $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?", array($this->id));
     $prev_reminder_interval = $adb->query_result($query_prev_interval, 0, 'reminder_interval');
     //$focus->imagename = $image_upload_array['imagename'];
     $this->saveHomeStuffOrder($this->id);
     SaveTagCloudView($this->id);
     // Added for Reminder Popup support
     $this->resetReminderInterval($prev_reminder_interval);
     //Creating the Privileges Flat File
     if (isset($this->column_fields['roleid'])) {
         updateUser2RoleMapping($this->column_fields['roleid'], $this->id);
     }
     //After adding new user, set the default activity types for new user
     Vtiger_Util_Helper::setCalendarDefaultActivityTypesForUser($this->id);
     require_once 'modules/Users/CreateUserPrivilegeFile.php';
     createUserPrivilegesfile($this->id);
     createUserSharingPrivilegesfile($this->id);
 }
Example #2
0
 // Added for Reminder Popup support
 $focus->resetReminderInterval($prev_reminder_interval);
 $return_id = $focus->id;
 if (isset($_POST['user_name']) && isset($_POST['new_password'])) {
     $new_pass = $_POST['new_password'];
     $new_passwd = $_POST['new_password'];
     $new_pass = md5($new_pass);
     $uname = $_POST['user_name'];
     if (!$focus->change_password($_POST['confirm_new_password'], $_POST['new_password'])) {
         header("Location: index.php?action=Error&module=Users&error_string=" . urlencode($focus->error_string));
         exit;
     }
 }
 if (isset($focus->id) && $focus->id != '') {
     if (isset($_POST['user_role'])) {
         updateUser2RoleMapping($_POST['user_role'], $focus->id);
     }
     if (isset($_POST['group_name']) && $_POST['group_name'] != '') {
         updateUsers2GroupMapping($_POST['group_name'], $focus->id);
     }
 } else {
     if (isset($_POST['user_role'])) {
         insertUser2RoleMapping($_POST['user_role'], $focus->id);
     }
     if (isset($_POST['group_name'])) {
         insertUsers2GroupMapping($_POST['group_name'], $focus->id);
     }
 }
 //Creating the Privileges Flat File
 require_once 'modules/Users/CreateUserPrivilegeFile.php';
 createUserPrivilegesfile($focus->id);
Example #3
0
    /** Function to save the user information into the database
     * @param $module -- module name:: Type varchar
     *
     */
    function save($module_name) {
        global $log, $adb;
        //Save entity being called with the modulename as parameter
        $this->saveentity($module_name);

        // Added for Reminder Popup support
        $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?",
                array($this->id));
        $prev_reminder_interval = $adb->query_result($query_prev_interval,0,'reminder_interval');

        //$focus->imagename = $image_upload_array['imagename'];
        $this->saveHomeStuffOrder($this->id);
        SaveTagCloudView($this->id);

        // Added for Reminder Popup support
        $this->resetReminderInterval($prev_reminder_interval);
        //Creating the Privileges Flat File
        if(isset($this->column_fields['roleid'])) {
            updateUser2RoleMapping($this->column_fields['roleid'],$this->id);
        }

		//After adding new user, set the default activity types for new user
		Vtiger_Util_Helper::setCalendarDefaultActivityTypesForUser($this->id);

        require_once('modules/Users/CreateUserPrivilegeFile.php');
        createUserPrivilegesfile($this->id);
        createUserSharingPrivilegesfile($this->id);

    }
Example #4
0
 /** Function to save the user information into the database
  * @param $module -- module name:: Type varchar
  */
 function save($module_name, $fileid = '')
 {
     global $log, $adb, $current_user;
     if (!is_admin($current_user) and $current_user->id != $this->id) {
         // only admin users can change other users profile
         return false;
     }
     $userrs = $adb->pquery('select roleid from vtiger_user2role where userid = ?', array($this->id));
     $oldrole = $adb->query_result($userrs, 0, 0);
     //Save entity being called with the modulename as parameter
     $this->saveentity($module_name);
     // Added for Reminder Popup support
     $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?", array($this->id));
     $prev_reminder_interval = $adb->query_result($query_prev_interval, 0, 'reminder_interval');
     //$focus->imagename = $image_upload_array['imagename'];
     $this->saveHomeStuffOrder($this->id);
     SaveTagCloudView($this->id);
     // Added for Reminder Popup support
     $this->resetReminderInterval($prev_reminder_interval);
     //Creating the Privileges Flat File
     if (isset($this->column_fields['roleid'])) {
         updateUser2RoleMapping($this->column_fields['roleid'], $this->id);
     }
     require_once 'modules/Users/CreateUserPrivilegeFile.php';
     //createUserPrivilegesfile($this->id); // done in saveentity above
     if ($this->mode != 'edit' or $oldrole != $this->column_fields['roleid']) {
         createUserSharingPrivilegesfile($this->id);
     }
 }
Example #5
0
 /** Function to save the user information into the database
  * @param $module -- module name:: Type varchar
  *
  */
 function save($module_name)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     if ($this->mode != 'edit') {
         $sql = 'SELECT id FROM vtiger_users WHERE user_name = ? OR email1 = ?';
         $result = $adb->pquery($sql, array($this->column_fields['user_name'], $this->column_fields['email1']));
         if ($adb->num_rows($result) > 0) {
             Vtiger_Functions::throwNewException('LBL_USER_EXISTS');
             throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_USER_EXISTS'));
             return false;
         }
     }
     //Save entity being called with the modulename as parameter
     $this->saveentity($module_name);
     // Added for Reminder Popup support
     $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?", array($this->id));
     $prev_reminder_interval = $adb->query_result($query_prev_interval, 0, 'reminder_interval');
     //$focus->imagename = $image_upload_array['imagename'];
     $this->saveHomeStuffOrder($this->id);
     SaveTagCloudView($this->id);
     // Added for Reminder Popup support
     $this->resetReminderInterval($prev_reminder_interval);
     //Creating the Privileges Flat File
     if (isset($this->column_fields['roleid'])) {
         updateUser2RoleMapping($this->column_fields['roleid'], $this->id);
     }
     //After adding new user, set the default activity types for new user
     Vtiger_Util_Helper::setCalendarDefaultActivityTypesForUser($this->id);
     require_once 'modules/Users/CreateUserPrivilegeFile.php';
     createUserPrivilegesfile($this->id);
     createUserSharingPrivilegesfile($this->id);
 }