예제 #1
0
 /**
  * Returns the last changes, if there are any, for a specific module and item id.
  *
  * The result data is used by Mail_Notification class, when telling the users related
  * to an item that it has been modified.
  *
  * @param Phprojekt_Item_Abstract $object The item object
  *
  * @return array Array with 'userId', 'moduleId', 'itemId', 'field', 'label',
  *                          'oldValue', 'newValue', 'action' and 'datetime'.
  */
 public function getLastHistoryData($object)
 {
     $result = array();
     $moduleId = Phprojekt_Module::getId($object->getModelName());
     $itemId = $object->id;
     $where = sprintf('module_id = %d AND item_id = %d', (int) $moduleId, (int) $itemId);
     $datetime = null;
     $action = null;
     $history = $this->fetchAll($where, 'id DESC');
     $stop = false;
     foreach ($history as $row) {
         if (!$stop) {
             if (null === $datetime) {
                 $datetime = $row->datetime;
                 $action = $row->action;
             }
             if ($action == $row->action) {
                 $diff = abs(strtotime($datetime) - strtotime($row->datetime));
                 if ($diff < 1) {
                     $result[] = array('userId' => $row->userId, 'moduleId' => $row->moduleId, 'itemId' => $row->itemId, 'field' => $row->field, 'oldValue' => $row->oldValue, 'newValue' => $row->newValue, 'action' => $row->action, 'datetime' => $row->datetime);
                 } else {
                     $stop = true;
                     break;
                 }
             } else {
                 $stop = true;
                 break;
             }
         }
     }
     return array_reverse($result);
 }
예제 #2
0
 /**
  * Delete all the entries for one object.
  *
  * @param Phprojekt_Item_Abstract $object The item object.
  *
  * @return void
  */
 public function deleteObjectItem($object)
 {
     $moduleId = Phprojekt_Module::getId($object->getModelName());
     $itemId = $object->id;
     $wordsId = $this->_wordModule->deleteWords($moduleId, $itemId);
     $this->_words->decreaseWords($wordsId);
     $this->_display->deleteDisplay($moduleId, $itemId);
 }
예제 #3
0
 /**
  * Delete all the entries for one object.
  *
  * @param Phprojekt_Item_Abstract $object The item object.
  *
  * @return void
  */
 public function deleteObjectItem($object)
 {
     $moduleId = Phprojekt_Module::getId($object->getModelName());
     $itemId = $object->id;
     $this->deleteObjectItemByIds($moduleId, $itemId);
 }