示例#1
0
文件: File.php 项目: sebbie42/casebox
 /**
  * update objects custom data
  * @return void
  */
 protected function updateCustomData()
 {
     parent::updateCustomData();
     $updated = DM\Files::update(array('id' => $this->id, 'content_id' => @$this->data['content_id'], 'date' => @$this->data['date'], 'name' => @$this->data['name'], 'cid' => @$this->data['cid'], 'uid' => User::getId()));
     //create record if doesnt exist yet
     if (!$updated) {
         DM\Files::create(array('id' => $this->id, 'content_id' => @$this->data['content_id'], 'date' => @$this->data['date'], 'name' => @$this->data['name'], 'cid' => @$this->data['cid']));
     }
 }
示例#2
0
 public function updateFileProperties($p)
 {
     if (empty($p['id'])) {
         return array('success' => false, 'msg' => L\get('Wrong_input_data'));
     }
     if (!Security::canWrite($p['id'])) {
         return array('success' => false, 'msg' => L\get('Access_denied'));
     }
     $p['title'] = strip_tags(@$p['title']);
     DM\Files::update(array('id' => $p['id'], 'date' => Util\dateISOToMysql($p['date']), 'title' => @$p['title'], 'uid' => User::getId(), 'udate' => 'CURRENT_TIMESTAMP'));
     Objects::updateCaseUpdateInfo($p['id']);
     return array('success' => true);
 }
示例#3
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;
 }