Ejemplo n.º 1
0
 public function deleteUserPermanently($userId, $newOwnerId)
 {
     global $shared_owners;
     $db = PearDatabase::getInstance();
     $sql = "UPDATE vtiger_crmentity SET smcreatorid=?,smownerid=? WHERE smcreatorid=? AND setype=?";
     $db->pquery($sql, array($newOwnerId, $newOwnerId, $userId, 'ModComments'));
     //update history details in vtiger_modtracker_basic
     $sql = "update vtiger_modtracker_basic set whodid=? where whodid=?";
     $db->pquery($sql, array($newOwnerId, $userId));
     //update comments details in vtiger_modcomments
     $sql = "update vtiger_modcomments set userid=? where userid=?";
     $db->pquery($sql, array($newOwnerId, $userId));
     $sql = "DELETE FROM vtiger_users WHERE id=?";
     $db->pquery($sql, array($userId));
     if ($shared_owners) {
         Users_Privileges_Model::setAllSharedOwner($userId, true);
     }
 }
Ejemplo n.º 2
0
 /** Function to save the user information into the database
  * @param $module -- module name:: Type varchar
  *
  */
 function saveentity($module)
 {
     global $current_user, $shared_owners;
     //$adb added by raju for mass mailing
     $insertion_mode = $this->mode;
     if (empty($this->column_fields['time_zone'])) {
         $dbDefaultTimeZone = DateTimeField::getDBTimeZone();
         $this->column_fields['time_zone'] = $dbDefaultTimeZone;
         $this->time_zone = $dbDefaultTimeZone;
     }
     if (empty($this->column_fields['currency_id'])) {
         $this->column_fields['currency_id'] = CurrencyField::getDBCurrencyId();
     }
     if (empty($this->column_fields['date_format'])) {
         $this->column_fields['date_format'] = 'yyyy-mm-dd';
     }
     if (empty($this->column_fields['start_hour'])) {
         $this->column_fields['start_hour'] = '08:00';
     }
     if (empty($this->column_fields['dayoftheweek'])) {
         $this->column_fields['dayoftheweek'] = 'Monday';
     }
     if (empty($this->column_fields['callduration'])) {
         $this->column_fields['callduration'] = 5;
     }
     if (empty($this->column_fields['othereventduration'])) {
         $this->column_fields['othereventduration'] = 5;
     }
     if (empty($this->column_fields['hour_format'])) {
         $this->column_fields['hour_format'] = 24;
     }
     if (empty($this->column_fields['activity_view'])) {
         $this->column_fields['activity_view'] = 'This Month';
     }
     if (empty($this->column_fields['calendarsharedtype'])) {
         $this->column_fields['calendarsharedtype'] = 'public';
     }
     if (empty($this->column_fields['default_record_view'])) {
         $this->column_fields['default_record_view'] = 'Summary';
     }
     if (empty($this->column_fields['status'])) {
         $this->column_fields['status'] = 'Active';
     }
     if (empty($this->column_fields['currency_decimal_separator']) && $this->column_fields['currency_decimal_separator'] != ' ') {
         $this->column_fields['currency_decimal_separator'] = '.';
     }
     if (empty($this->column_fields['currency_grouping_separator']) && $this->column_fields['currency_grouping_separator'] != ' ') {
         $this->column_fields['currency_grouping_separator'] = ' ';
     }
     $this->db->println("TRANS saveentity starts {$module}");
     $this->db->startTransaction();
     foreach ($this->tab_name as $table_name) {
         if ($table_name == 'vtiger_attachments') {
             $this->insertIntoAttachment($this->id, $module);
         } else {
             $this->insertIntoEntityTable($table_name, $module);
         }
     }
     if (Settings_Roles_Record_Model::getInstanceById($this->column_fields['roleid']) == null) {
         $roleid = Settings_Roles_Record_Model::getInstanceByName($this->column_fields['roleid']);
         if ($roleid) {
             $this->column_fields['roleid'] = $roleid->getId();
         } else {
             $roles = Settings_Roles_Record_Model::getAll();
             $this->column_fields['roleid'] = key($roles);
         }
     }
     require_once 'modules/Users/CreateUserPrivilegeFile.php';
     createUserPrivilegesfile($this->id);
     unset($_SESSION['next_reminder_interval']);
     unset($_SESSION['next_reminder_time']);
     if ($insertion_mode != 'edit') {
         $this->createAccessKey();
         if ($shared_owners) {
             Users_Privileges_Model::setAllSharedOwner($this->id);
         }
     }
     $this->db->completeTransaction();
     $this->db->println("TRANS saveentity ends");
 }