Ejemplo n.º 1
0
 /**
  * Validate data before save
  *
  * @access public
  * @param array $errors
  * @return void
  */
 function validate(&$errors)
 {
     if (!isset($this->perform_validation) || $this->perform_validation) {
         // Validate min length for the password
         if (!ContactPasswords::validateMinLength($this->password_temp)) {
             $min_pass_length = config_option('min_password_length', 0);
             $errors[] = lang('password invalid min length', $min_pass_length);
         }
         // if
         // Validate password numbers
         if (!ContactPasswords::validateNumbers($this->password_temp)) {
             $pass_numbers = config_option('password_numbers', 0);
             $errors[] = lang('password invalid numbers', $pass_numbers);
         }
         // if
         // Validate uppercase characters
         if (!ContactPasswords::validateUppercaseCharacters($this->password_temp)) {
             $pass_uppercase = config_option('password_uppercase_characters', 0);
             $errors[] = lang('password invalid uppercase', $pass_uppercase);
         }
         // if
         // Validate metacharacters
         if (!ContactPasswords::validateMetacharacters($this->password_temp)) {
             $pass_metacharacters = config_option('password_metacharacters', 0);
             $errors[] = lang('password invalid metacharacters', $pass_metacharacters);
         }
         // if
         // Validate against password history
         if (!ContactPasswords::validateAgainstPasswordHistory($this->getContactId(), $this->password_temp)) {
             $errors[] = lang('password exists history');
         }
         // if
         // Validate new password character difference
         if (!ContactPasswords::validateCharDifferences($this->getContactId(), $this->password_temp)) {
             $errors[] = lang('password invalid difference');
         }
         // if
     }
 }
Ejemplo n.º 2
0
 /**
  * Send password expiration reminders to contacts
  *
  * @access public
  * @return int
  */
 static function sendPasswordExpirationReminders()
 {
     $sent = 0;
     $password_expiration_days = config_option('password_expiration', 0);
     $password_expiration_notification = config_option('password_expiration_notification', 0);
     $contact_passwords = ContactPasswords::getNewestContactPasswords();
     foreach ($contact_passwords as $password) {
         $diff_days = self::getContactPasswordDays($password);
         if ($diff_days == $password_expiration_days - $password_expiration_notification) {
             $contact = Contacts::findById($password->getContactId());
             if ($contact instanceof Contact) {
                 if (Notifier::passwordExpiration($contact, $password_expiration_notification)) {
                     $sent++;
                 }
             }
         }
     }
     return $sent;
 }
Ejemplo n.º 3
0
 function do_delete()
 {
     $id = $this->getId();
     ContactAddresses::instance()->delete("`contact_id` = {$id}");
     ContactImValues::instance()->delete("`contact_id` = {$id}");
     ContactEmails::instance()->delete("`contact_id` = {$id}");
     ContactTelephones::instance()->delete("`contact_id` = {$id}");
     ContactWebpages::instance()->delete("`contact_id` = {$id}");
     ContactConfigOptionValues::instance()->delete("`contact_id` = {$id}");
     ContactPasswords::instance()->delete("`contact_id` = {$id}");
     ObjectSubscriptions::instance()->delete("`contact_id` = {$id}");
     ObjectReminders::instance()->delete("`contact_id` = {$id}");
     ContactPermissionGroups::instance()->delete("`contact_id` = {$id}");
     ContactMemberPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     ContactDimensionPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     SystemPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     TabPanelPermissions::instance()->delete("`permission_group_id` = " . $this->getPermissionGroupId());
     $this->delete();
     $ret = null;
     Hook::fire("after_user_deleted", $this, $ret);
 }
Ejemplo n.º 4
0
 /**
  * Show and change password form
  *
  * @param void
  * @return null
  */
 function change_password()
 {
     $user = Contacts::findById(get_id());
     if (!($user instanceof Contact && $user->isUser()) || $user->getDisabled()) {
         return;
     }
     tpl_assign('user_id', get_id());
     if (array_var($_GET, 'msg') && array_var($_GET, 'msg') == 'expired') {
         $reason = lang('password expired');
     } else {
         $reason = lang('password invalid');
     }
     tpl_assign('reason', $reason);
     if (is_array(array_var($_POST, 'changePassword'))) {
         $changePassword_data = array_var($_POST, 'changePassword');
         $username = array_var($changePassword_data, 'username');
         $old_password = array_var($changePassword_data, 'oldPassword');
         $new_password = array_var($changePassword_data, 'newPassword');
         $repeat_password = array_var($changePassword_data, 'repeatPassword');
         if (trim($username) != $user->getUsername()) {
             tpl_assign('error', new Error(lang('invalid login data')));
             $this->render();
         }
         if (trim($old_password) == '') {
             tpl_assign('error', new Error(lang('old password required')));
             $this->render();
         }
         // if
         if (!$user->isValidPassword($old_password)) {
             tpl_assign('error', new Error(lang('invalid old password')));
             $this->render();
         }
         // if
         if (trim($new_password == '')) {
             tpl_assign('error', new Error(lang('password value missing')));
             $this->render();
         }
         // if
         if ($new_password != $repeat_password) {
             tpl_assign('error', new Error(lang('passwords dont match')));
             $this->render();
         }
         // if
         if (!ContactPasswords::validateMinLength($new_password)) {
             $min_pass_length = config_option('min_password_length', 0);
             tpl_assign('error', new Error(lang('password invalid min length', $min_pass_length)));
             $this->render();
         }
         if (!ContactPasswords::validateNumbers($new_password)) {
             $pass_numbers = config_option('password_numbers', 0);
             tpl_assign('error', new Error(lang('password invalid numbers', $pass_numbers)));
             $this->render();
         }
         if (!ContactPasswords::validateUppercaseCharacters($new_password)) {
             $pass_uppercase = config_option('password_uppercase_characters', 0);
             tpl_assign('error', new Error(lang('password invalid uppercase', $pass_uppercase)));
             $this->render();
         }
         if (!ContactPasswords::validateMetacharacters($new_password)) {
             $pass_metacharacters = config_option('password_metacharacters', 0);
             tpl_assign('error', new Error(lang('password invalid metacharacters', $pass_metacharacters)));
             $this->render();
         }
         if (!ContactPasswords::validateAgainstPasswordHistory($user->getId(), $new_password)) {
             tpl_assign('error', new Error(lang('password exists history')));
             $this->render();
         }
         if (!ContactPasswords::validateCharDifferences($user->getId(), $new_password)) {
             tpl_assign('error', new Error(lang('password invalid difference')));
             $this->render();
         }
         $user_password = new ContactPassword();
         $user_password->setPasswordDate(DateTimeValueLib::now());
         $user_password->setContactId($user->getId());
         $user_password->setPassword(cp_encrypt($new_password, $user_password->getPasswordDate()->getTimestamp()));
         $user_password->password_temp = $new_password;
         $user_password->save();
         $user->setPassword($new_password);
         $user->save();
         try {
             CompanyWebsite::instance()->logUserIn($user, $remember);
         } catch (Exception $e) {
             tpl_assign('error', new Error(lang('invalid login data')));
             $this->render();
         }
         // try
         $ref_controller = null;
         $ref_action = null;
         $ref_params = array();
         foreach ($login_data as $k => $v) {
             if (str_starts_with($k, 'ref_')) {
                 $ref_var_name = trim(substr($k, 4, strlen($k)));
                 switch ($ref_var_name) {
                     case 'c':
                         $ref_controller = $v;
                         break;
                     case 'a':
                         $ref_action = $v;
                         break;
                     default:
                         $ref_params[$ref_var_name] = $v;
                 }
                 // switch
             }
             // if
         }
         // if
         if (!count($ref_params)) {
             $ref_params = null;
         }
         if ($ref_controller && $ref_action) {
             $this->redirectTo($ref_controller, $ref_action, $ref_params);
         } else {
             //$this->redirectTo('dashboard');
             header("Location: " . ROOT_URL);
             exit;
         }
         // if
     }
 }
 /**
  * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted
  *
  * @access public
  * @param string $conditions Query conditions
  * @return boolean
  */
 function delete($condition = null)
 {
     if (isset($this) && instance_of($this, 'ContactPasswords')) {
         return parent::delete($condition);
     } else {
         return ContactPasswords::instance()->delete($condition);
     }
     // if
 }
Ejemplo n.º 6
0
function send_password_expiration_reminders(){
	$password_expiration_notification = config_option('password_expiration_notification', 0);
	if($password_expiration_notification > 0){
		_log("Sending password expiration reminders...");
		$count = ContactPasswords::sendPasswordExpirationReminders();
		_log("$count password expiration reminders sent.");
	}
}
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ContactPasswords 
  */
 function manager()
 {
     if (!$this->manager instanceof ContactPasswords) {
         $this->manager = ContactPasswords::instance();
     }
     return $this->manager;
 }
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return ContactPasswords 
 */
 function manager() {
   if(!($this->manager instanceof ContactPasswords)) $this->manager = ContactPasswords::instance();
   return $this->manager;
 } // manager