/**
  * Locks the current item.
  *
  * Locks is only meant for write actions like change, while an item should
  * be anyway accessible in read only mode when locked.
  *
  * @todo The system should support automatic expiry of locks after n
  * seconds, and an optional alert to the user (eg. a javascript alert).
  *
  * @todo This method should optionally accept a max lock time in seconds.
  *
  * @access public
  * @return void
  */
 public function lock()
 {
     $sem = new \Innomatic\Process\Semaphore('innoworkitem_' . $this->mItemType, $this->mItemId);
     $sem->setRed();
 }
Beispiel #2
0
 public function destroy()
 {
     $result = false;
     $sem = new \Innomatic\Process\Semaphore('cache', $this->mItemFile);
     $sem->waitGreen();
     $sem->setRed();
     if (strlen($this->mItemFile) and file_exists($this->mItemFile)) {
         $result = @unlink($this->mItemFile);
     } else {
         $this->mResult = CachedItem::ITEM_NOT_FOUND;
     }
     if ($result) {
         $result = $this->mrRootDb->execute('DELETE FROM cache_items WHERE application=' . $this->mrRootDb->formatText($this->mApplication) . ' AND itemid=' . $this->mrRootDb->formatText($this->mItemId));
     }
     $sem->setGreen();
     return $result;
 }
 /**
  * Svuota il contenuto della clipboard.
  * @return bool
  * @access public
  */
 public function erase()
 {
     $result = false;
     if ($this->IsValid()) {
         $sem = new \Innomatic\Process\Semaphore('clipboard', $this->fileName);
         $sem->waitGreen();
         $sem->setRed();
         $result = unlink($this->fileName);
         $sem->setGreen();
     } else {
         $result = true;
     }
     return $result;
 }