Example #1
0
 public function beforeSave()
 {
     if ($this->isNewRecord()) {
         $this->added_by = WebApp::get()->user()->id;
         $this->added_time = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
     // TODO: Change the autogenerated stub
 }
Example #2
0
 public function beforeSave()
 {
     if (WebApp::get()->user()->isConnected()) {
         $this->user_id = WebApp::get()->user()->id;
         $this->username = WebApp::get()->user()->name;
         $this->email = WebApp::get()->user()->email;
     } elseif (!trim($this->email)) {
         $this->setError('email', 'Email is required  for guests!');
         return false;
     } elseif (!trim($this->username)) {
         $this->setError('username', 'Name is required for quests!');
         return false;
     }
     $this->published_time = date('Y-m-d H:i:s');
     $this->status = BlogComment::STATUS_OK;
     return parent::beforeSave();
     // TODO: Change the autogenerated stub
 }
 public function beforeDelete()
 {
     if (!UserAccess::get()->isCategoryAdmin($this->category_id, $this->category->section_id)) {
         Messages::get()->error("You can't delete this category!");
         return false;
     }
     return parent::beforeDelete();
 }
Example #4
0
 public function beforeDelete()
 {
     App::get()->sql()->table('users2groups')->where('group_id = :group')->setParam(':group', $this->id)->delete();
     //delete connections from this group to users
     return parent::beforeDelete();
 }
Example #5
0
 /**
  * Before deleting user delete every other tables connected to it.
  * @return bool|void
  */
 public function beforeDelete()
 {
     App::get()->sql()->table('users2groups')->where("user_id = :id")->setParam(':id', $this->id)->delete();
     UserHistory::deleteAllByAttributes(['user_id' => $this->id]);
     UserConfig::deleteAllByAttributes(['user_id' => $this->id]);
     return parent::beforeDelete();
 }
 public function beforeSave()
 {
     if (is_a(App::get(), '\\mpf\\WebApp') && WebApp::get()->request()->getModule()) {
         if (!UserAccess::get()->isSectionAdmin($this->section_id)) {
             Messages::get()->error("You don't have access to edit this user group!");
             return false;
         }
     }
     return parent::beforeSave();
 }
Example #7
0
 public function beforeDelete()
 {
     User::updateAll(['title_id' => 0], "title_id = :title", array(':title' => $this->id));
     // update user titles to 0 where this id is used.
     return parent::beforeDelete();
 }