예제 #1
0
 /**
  * running background cron for updating tree changes into solr
  */
 public static function runBackgroundCron()
 {
     $coreName = \CB\Config::get('core_name');
     if (\CB\Config::getFlag('disableTriggers') || \CB\Config::getFlag('disableSolrIndexing')) {
         return;
     }
     $cmd = 'php -f "' . \CB\CRONS_DIR . 'run_cron.php" -- -n solr_update_tree -c ' . $coreName . ' > ' . \CB\LOGS_DIR . 'bg_solr_update_tree.log &';
     if (\CB\IS_WINDOWS) {
         $cmd = 'start /D "' . \CB\CRONS_DIR . '" php -f "run_cron.php" -- -n solr_update_tree -c ' . $coreName . ' > ' . \CB\LOGS_DIR . 'bg_solr_update_tree.log';
     }
     pclose(popen($cmd, "r"));
 }
예제 #2
0
파일: File.php 프로젝트: sebbie42/casebox
 /**
  * create method
  * @return void
  */
 public function create($p = false)
 {
     //disable default log from parent Object class
     //we'll set comments add as comment action for parent
     $disableLogFlag = \CB\Config::getFlag('disableActivityLog');
     \CB\Config::setFlag('disableActivityLog', true);
     $rez = parent::create($p);
     \CB\Config::setFlag('disableActivityLog', $disableLogFlag);
     $p =& $this->data;
     $this->parentObj = Objects::getCachedObject($p['pid']);
     $this->updateParentFollowers();
     $this->logAction('file_upload', array('file' => array('id' => $p['id'], 'name' => $p['name'])));
     return $rez;
 }
예제 #3
0
 /**
  * add an action to log
  * @param array $p action params
  *     array(
  *       @varchar "type" - action type
  *       ,object "old" - old object
  *       ,object "new" - new object
  *     )
  * @return int logged action id
  */
 public static function add(&$p)
 {
     $userId = User::getId();
     //check if log not disabled
     if (Config::getFlag('disableActivityLog') || empty($userId)) {
         return;
     }
     $data = empty($p['new']) ? empty($p['old']) ? $p['data'] : $p['old']->getData() : $p['new']->getData();
     fireEvent('beforelogadd', $p);
     $p['logData'] = static::getLogData($p);
     $p['activityData'] = static::getActivityData($data);
     $params = array('object_id' => $data['id'], 'object_pid' => @$data['pid'], 'user_id' => $userId, 'action_type' => $p['type'], 'data' => Util\jsonEncode($p['logData']), 'activity_data_db' => Util\jsonEncode($p['activityData']));
     $p['action_id'] = DM\Log::create($params);
     $params['id'] = $p['action_id'];
     static::addSolrRecord($p);
     static::addNotificationRecords($params);
     fireEvent('logadd', $p);
     return $p['action_id'];
 }
 public function setUp()
 {
     $this->oldValues = array('user_id' => $_SESSION['user']['id'], 'userVerified' => empty($_SESSION['verified']), 'solrIndexing' => \CB\Config::getFlag('disableSolrIndexing'));
     $_SESSION['verified'] = true;
     \CB\Config::setFlag('disableSolrIndexing', true);
     /* create users */
     $usersData = Data\Providers::createUsersData();
     $this->userIds = array();
     foreach ($usersData[0] as $data) {
         $this->userIds[] = $this->createUser($data);
     }
     /* create objects for test notifications on them */
     $objectsData = Data\Providers::createTasksData();
     $userIds = $this->userIds;
     $id = array_shift($userIds);
     array_push($userIds, $id);
     foreach ($objectsData[0] as $data) {
         $data['data']['assigned'] = array_shift($userIds);
         $this->objectIds[] = $this->createObject($data);
     }
 }
예제 #5
0
 public function setUp()
 {
     $this->oldValues = array('user_id' => $_SESSION['user']['id'], 'userVerified' => empty($_SESSION['verified']), 'solrIndexing' => Config::getFlag('disableSolrIndexing'));
     $_SESSION['verified'] = true;
     Config::setFlag('disableSolrIndexing', true);
 }
예제 #6
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);
     }
 }
예제 #7
0
 /**
  * save or create an object
  * @param  array $p object properties
  * @return json  responce
  */
 public function save($p)
 {
     $d = Util\toJSONArray($p['data']);
     // check if need to create object instead of update
     if (empty($d['id']) || !is_numeric($d['id'])) {
         return $this->create($d);
     }
     // SECURITY: check if current user has write access to this action
     if (!Security::canWrite($d['id'])) {
         throw new \Exception(L\get('Access_denied'));
     }
     /* prepare params */
     if (empty($d['date']) && !empty($d['date_start'])) {
         $d['date'] = $d['date_start'];
     }
     /* end of prepare params */
     // update object
     $object = $this->getCachedObject($d['id']);
     //set sys_data from object, it can contain custom data
     //that shouldn't be overwritten
     $d['sys_data'] = $object->getSysData();
     $object->update($d);
     Objects::updateCaseUpdateInfo($d['id']);
     /* updating saved document into solr directly (before runing background cron)
        so that it'll be displayed with new name without delay */
     if (!\CB\Config::getFlag('disableSolrIndexing')) {
         $solrClient = new Solr\Client();
         $solrClient->updateTree(array('id' => $d['id']));
         //running background cron to index other nodes
         $solrClient->runBackgroundCron();
     }
     return $this->load($d);
 }