Example #1
0
 /**
  * Create the object
  * @param array $exclude Attributes not to set
  * @return boolean
  */
 public function Create($exclude = array())
 {
     // Get the next value if there is none
     if (!$this->iget('value')) {
         $this->iset('value', 1 + (int) $this->getValue(array('select' => 'MAX(value)', 'where' => array(array('module_id', $this->iget('module_id'))))));
     }
     // Call parent
     return parent::Create($exclude);
 }
Example #2
0
 /**
  * Create a new user
  * @param array $exclude Attributes not to set
  * @param \PDO $db Database connection to use, default to master resource
  * @return boolean
  */
 public function Create($exclude = array(), &$db = FALSE)
 {
     // Check email is unique
     if (!$this->uniqueEmail()) {
         // Set message
         new \Sonic\Message('error', 'The email address `' . $this->iget('email') . '` is already assigned to an account! Please choose another.');
         // Return FALSE
         return FALSE;
     }
     // Hash password
     $password = $this->iget('password');
     $this->iset('password', self::_Hash($password));
     // Call parent method
     $parent = parent::Create($exclude, $db);
     // Reset password
     $this->iset('password', $password);
     // Return
     return $parent;
 }