예제 #1
0
 /**
  * update comment
  * @param  array   $p optional properties. If not specified then $this-data is used
  * @return boolean
  */
 public function update($p = false)
 {
     //disable default log from parent Object class
     //we'll set comments add as comment action for parent
     Config::setFlag('disableActivityLog', true);
     $rez = parent::update($p);
     Config::setFlag('disableActivityLog', false);
     $p =& $this->data;
     // log the action
     $logParams = array('type' => 'comment_update', 'new' => Objects::getCachedObject($p['pid']), 'comment' => $p['data']['_title']);
     Log::add($logParams);
     return $rez;
 }
예제 #2
0
 /**
  * add action to log
  * @param  varchar $type
  * @param  array   $params
  * @return void
  */
 protected function logAction($type, $params = array())
 {
     if (!Cache::get('disable_logs', false) && !Config::getFlag('disableActivityLog')) {
         $params['type'] = $type;
         $obj =& $this;
         if (empty($params['new'])) {
             $params['new'] =& $this;
         } else {
             $obj =& $params['new'];
         }
         $logActionId = Log::add($params);
         $uid = User::getId();
         //add action to object sys_data
         $data = $obj->getData();
         $lastAction = $obj->getLastActionData();
         if ($lastAction['type'] != $type) {
             $lastAction = array('type' => $type, 'time' => Util\dateMysqlToISO('now'), 'users' => array());
         }
         /*$sysData = empty($data['sys_data'])
                         ? $this->getSysData()
                         : $data['sys_data'];
         
                     $lastAction = array(
                         'type' => $type
                         ,'time' => Util\dateMysqlToISO('now')
                         ,'users' => array()
                     );
         
                     if (!empty($sysData['lastAction']) &&
                         ($sysData['lastAction']['type'] == $type)
                     ) {
                         $lastAction['users'] = $sysData['lastAction']['users'];
                     } /**/
         unset($lastAction['users'][$uid]);
         $lastAction['users'][$uid] = $logActionId;
         $obj->setSysDataProperty('lastAction', $lastAction);
     }
 }
예제 #3
0
 /**
  * update file
  * @param  array   $p optional properties. If not specified then $this-data is used
  * @return boolean
  */
 public function update($p = false)
 {
     //disable default log from parent Object class
     Config::setFlag('disableActivityLog', true);
     $rez = parent::update($p);
     Config::setFlag('disableActivityLog', false);
     $p =& $this->data;
     // log the action
     $logParams = array('type' => 'file_update', 'new' => Objects::getCachedObject($p['pid']), 'file' => array('id' => $p['id'], 'name' => $p['name']));
     Log::add($logParams);
     return $rez;
 }
예제 #4
0
 /**
  * move an object to $pid or over $targetId
  *
  * we'll use the same principle as for copy
  *
  * @param  int $pid      if not specified then will be set to pid of targetId
  * @param  int $targetId
  * @return int the id of moved object or false
  */
 public function moveTo($pid = false, $targetId = false)
 {
     // check input params
     if (!is_numeric($this->id) || !is_numeric($pid) && !is_numeric($targetId)) {
         return false;
     }
     /* security check */
     if (!\CB\Security::canRead($this->id)) {
         return false;
     }
     /* end of security check */
     //load current object from db into a variable to be passed to log and events
     $this->oldObject = clone $this;
     $this->oldObject->load($this->id);
     if (is_numeric($targetId)) {
         /* target security check */
         if (!\CB\Security::canWrite($targetId)) {
             return false;
         }
         /* end of target security check */
         // marking overwriten object with dstatus = 3
         DB\dbQuery('UPDATE tree
             SET updated = 1
                 ,dstatus = 3
                 ,did = $2
             WHERE id = $1', array($targetId, $_SESSION['user']['id'])) or die(DB\dbQueryError());
         //get pid from target if not specified
         $res = DB\dbQuery('SELECT pid FROM tree WHERE id = $1', $targetId) or die(DB\dbQueryError());
         if ($r = $res->fetch_assoc()) {
             $pid = $r['pid'];
         }
         $res->close();
     } else {
         /* pid security check */
         if (!\CB\Security::canWrite($pid)) {
             return false;
         }
         /* end of pid security check */
     }
     /* check again if we have pid set
            It can be unset when not existent $targetId is specified
        */
     if (!is_numeric($pid)) {
         return false;
     }
     // moving the object to $pid
     DB\dbQuery('UPDATE tree
         SET updated = 1
             ,pid = $2
         WHERE id = $1', array($this->id, $pid)) or die(DB\dbQueryError());
     $this->moveCustomDataTo($pid);
     // move childs from overwriten targetId (which has been marked with dstatus = 3)
     // to newly copied object
     if (is_numeric($targetId)) {
         DB\dbQuery('UPDATE tree
             SET updated = 1
                 ,pid = $2
             WHERE pid = $1 AND
                 dstatus = 0', array($targetId, $this->id)) or die(DB\dbQueryError());
     }
     $this->load();
     // log the action
     $logParams = array('type' => 'move', 'old' => $this->oldObject, 'new' => $this);
     Log::add($logParams);
     return $this->id;
 }