Exemple #1
0
 /**
  * Validates password
  * $post has $post['password'] and $post['password_confirm']
  * @param array $post
  * @return boolean
  */
 public function validatePassword($post)
 {
     // Validate password strength
     $score = BootWiki::checkPassword($post['password']);
     if ($score < 1) {
         BootWiki::setMessage('Invalid password. Password is ' . BootWiki::getPasswordDescription($score));
         return false;
     }
     // Validate password match
     if ($post['password'] != $post['password_confirm']) {
         BootWiki::setMessage('Password was not confirmed');
         return false;
     }
     return true;
 }
Exemple #2
0
 /**
  * Saves form data
  * @param array $post
  * @param array $upload_image
  */
 public function savePost($post, $upload_image)
 {
     // Import fields (ugly i know)
     $fields = 'title,alias,publish,featured,date,description,keywords,author,intro,html,visits';
     // Find record
     $bean = R::findOne('content', 'alias = ?', array($this->alias));
     if (empty($bean)) {
         $bean = R::dispense('content');
     } else {
         // Save last version
         $version = R::dispense('contentversion');
         $version->import($bean->export(), $fields);
         $version->date = date('Y-m-d H:i:s');
         $version->content = $bean;
         R::store($version);
     }
     // Import changes
     $bean->import($post, $fields);
     $bean->idiom = R::findOne('idiom', 'code = ?', array($post['idiom']));
     $new_image = Image::upload($upload_image);
     if ($new_image) {
         $bean->image = $new_image;
     }
     // Save
     try {
         R::store($bean);
         $this->importBean($bean);
     } catch (Exception $e) {
         BootWiki::setMessage($e->getMessage());
     }
 }