Esempio n. 1
0
 public static function lock($cid, $ctype)
 {
     // try to get user
     if (!($user = Pimcore_Tool_Admin::getCurrentUser())) {
         return false;
     }
     $lock = new self();
     $lock->setCid($cid);
     $lock->setCtype($ctype);
     $lock->setDate(time());
     $lock->setUserId($user->getId());
     $lock->setSessionId(session_id());
     $lock->save();
     return $lock;
 }
Esempio n. 2
0
 /**
  * This is used for user-permissions, pass a permission type (eg. list, view, save) an you know if the current user is allowed to perform the requested action
  *
  * @param string $type
  * @return boolean
  */
 public function isAllowed($type)
 {
     $currentUser = Pimcore_Tool_Admin::getCurrentUser();
     //everything is allowed for admin
     if ($currentUser->isAdmin()) {
         return true;
     }
     return $this->getResource()->isAllowed($type, $currentUser);
 }
Esempio n. 3
0
 public function save()
 {
     // check if there's a valid user
     if (!$this->getUser()) {
         // try to use the logged in user
         if (Pimcore::inAdmin()) {
             if ($user = Pimcore_Tool_Admin::getCurrentUser()) {
                 $this->setUser($user->getId());
             }
         }
     }
     $this->getResource()->save();
 }