Exemple #1
0
 public function getChildren(&$pathArray, $requestParams)
 {
     $this->path = $pathArray;
     $this->lastNode = @$pathArray[sizeof($pathArray) - 1];
     $this->requestParams = $requestParams;
     if (!$this->acceptedPath($pathArray, $requestParams)) {
         return;
     }
     $ourPid = @$this->config['pid'];
     if ($ourPid == '') {
         $ourPid = 0;
     }
     $this->createDefaultFilter();
     if (empty($this->lastNode) || $this->lastNode->id == $ourPid && get_class($this->lastNode) != get_class($this) || \CB\Objects::getType($this->lastNode->id) == 'case') {
         $rez = $this->getRootNodes();
     } else {
         switch ($this->lastNode->id) {
             case 'tasks':
                 $rez = $this->getDepthChildren2();
                 break;
             case 2:
             case 3:
                 $rez = $this->getDepthChildren3();
                 break;
             default:
                 $rez = $this->getChildrenTasks();
         }
     }
     return $rez;
 }
Exemple #2
0
 /**
  * check if current class is configured to return any result for
  * given path and request params
  * @param  array   &$pathArray
  * @param  array   &$requestParams
  * @return boolean
  */
 protected function acceptedPath(&$pathArray, &$requestParams)
 {
     $lastNode = null;
     if (empty($pathArray)) {
         return false;
     } else {
         $lastNode = $pathArray[sizeof($pathArray) - 1];
     }
     if ($lastNode instanceof Dbnode) {
         if (\CB\Objects::getType($lastNode->id) !== 'case') {
             return false;
         }
     } elseif (get_class($lastNode) != get_class($this)) {
         return false;
     }
     return true;
 }
Exemple #3
0
 /**
  * method to collect solr data from object data
  * according to template fields configuration
  * and store it in sys_data onder "solr" property
  * @return void
  */
 protected function collectSolrData()
 {
     parent::collectSolrData();
     $sd =& $this->data['sys_data']['solr'];
     $sd['target_type'] = Objects::getType($this->data['target_id']);
 }
Exemple #4
0
 /**
  * get an instance of the class designed for objectId (based on it's template type)
  * @param  int    $objectId
  * @return object
  */
 public static function getCustomClassByObjectId($objectId)
 {
     $type = Objects::getType($objectId);
     return Objects::getCustomClassByType($type, $objectId);
 }
Exemple #5
0
 public function rename($p)
 {
     $id = explode('/', $p['path']);
     $id = array_pop($id);
     $p['name'] = trim($p['name']);
     if (!is_numeric($id) || empty($p['name'])) {
         return array('success' => false);
     }
     /* check security access */
     if (!Security::canWrite($id)) {
         throw new \Exception(L\get('Access_denied'));
     }
     DB\dbQuery('UPDATE tree
         SET name = $1
         WHERE id = $2', array($p['name'], $id)) or die(DB\dbQueryError());
     switch (Objects::getType($id)) {
         case 'file':
             $p['name'] = Purify::filename($p['name']);
             DB\dbQuery('UPDATE files
                 SET name = $1
                 WHERE id = $2', array($p['name'], $id)) or die(DB\dbQueryError());
             break;
     }
     /*updating renamed document into solr directly (before runing background cron)
       so that it'll be displayed with new name without delay*/
     $solrClient = new Solr\Client();
     $solrClient->updateTree(array('id' => $id));
     //running background cron to index other nodes
     $solrClient->runBackgroundCron();
     $p['name'] = htmlspecialchars($p['name'], ENT_COMPAT);
     //get pid
     $pid = null;
     $res = DB\dbQuery('SELECT pid FROM tree WHERE id = $1', $id) or die(DB\dbQueryError());
     if ($r = $res->fetch_assoc()) {
         $pid = $r['pid'];
     }
     $res->close();
     return array('success' => true, 'data' => array('id' => $id, 'pid' => $pid, 'newName' => $p['name']));
 }
Exemple #6
0
 public function rename($p)
 {
     $id = explode('/', $p['path']);
     $id = array_pop($id);
     $p['name'] = trim($p['name']);
     if (!is_numeric($id) || empty($p['name'])) {
         return array('success' => false);
     }
     /* check security access */
     if (!Security::canWrite($id)) {
         throw new \Exception(L\get('Access_denied'));
     }
     $p['name'] = Purify::filename($p['name']);
     $rez = array('success' => true, 'data' => array('id' => $id, 'pid' => null, 'newName' => $p['name']));
     $objectType = Objects::getType($id);
     if ($objectType == 'shortcut') {
         $r = DM\Tree::read($id);
         if (!empty($r['target_id'])) {
             $id = $r['target_id'];
             $objectType = Objects::getType($id);
         }
     }
     DM\Tree::update(array('id' => $id, 'name' => $p['name']));
     if ($objectType == 'file') {
         DM\Files::update(array('id' => $id, 'name' => $p['name']));
     }
     /*updating renamed document into solr directly (before runing background cron)
       so that it'll be displayed with new name without delay*/
     $solrClient = new Solr\Client();
     $solrClient->updateTree(array('id' => $id));
     //running background cron to index other nodes
     $solrClient->runBackgroundCron();
     $p['name'] = htmlspecialchars($p['name'], ENT_COMPAT);
     //get pid
     $r = DM\Tree::read($rez['data']['id']);
     if (!empty($r['pid'])) {
         $rez['data']['pid'] = $r['pid'];
     }
     return $rez;
 }