示例#1
0
 /**
  * Register the file and location in the DB for quick search and indexing
  *
  * @param $path        Path to the file
  * @param $fileName    File name on the hard disk
  * @param $fileWeight    Weight in bytes
  * @param $type 3 letters extension
  * @param $usersId
  * @param $safinstancesId
  * @param array $params
  * @param string $desc
  * @return bool|mixed|string    id of the file or false on error
  */
 public function registerFileToDb($path, $fileName, $fileWeight, $type, $usersId, $safinstancesId, $params = array(), $desc = '')
 {
     $fileTypeDb = new Filtype();
     $fileTypeId = 1;
     $fileTypeRow = $fileTypeDb->fetchAll("ext = '" . substr($type, 0, 3) . "'");
     if (count($fileTypeRow) == 1) {
         $fileTypeId = $fileTypeRow[0]->id;
     }
     $data = array('label' => $fileName, 'desc' => $desc, 'filename' => $fileName, 'type' => $type, 'fweight' => $fileWeight, 'filtype_id' => $fileTypeId, 'users_id' => $usersId, 'safinstances_id' => $safinstancesId, 'datecreated' => new Zend_Db_Expr('NOW()'), 'datemodified' => new Zend_Db_Expr('NOW()'));
     $fileFile = new Filfiles();
     $files = $fileFile->fetchAll("filename = '{$fileName}' AND safinstances_id = '" . $safinstancesId . "' ");
     $countFiles = count($files);
     if ($countFiles == 1 && $params->calledBy == 'adminpeople' && isset($params->peopleId) && $params->peopleId > 0) {
         UsersOp::changeAvatar($params->peopleId, $files[0]['id']);
         return $files[0]['id'];
     } elseif ($countFiles == 1) {
         // Replace action, we should update the DB datas
         $fileId = $files->current()->id;
         if ($fileFile->update($data, 'id=' . $fileId)) {
             Sydney_Db_Trace::add('trace.event.upload_file [' . $data['filename'] . ']', 'adminfiles', Sydney_Tools::getTableName($fileFile), 'uploadfile', $fileId);
             return $files[0]['id'];
         } else {
             return false;
         }
     } elseif ($countFiles == 0) {
         if ($fileId = $fileFile->insert($data)) {
             // #18 - called by module adminpeople In this case, check if the category 'module > system > adminpeople' exist, if yes then link to this else first create new cat and link this new cat.
             if ($params->calledBy == 'adminpeople') {
                 UsersOp::changeAvatar($params->peopleId, $fileId);
             }
             // add categories to file
             if (isset($params->catids)) {
                 $foids = explode(',', $params->catids);
                 $foids2 = array();
                 for ($i = 0; $i < count($foids); $i++) {
                     if ($foids[$i] > 0) {
                         $foids2[] = $foids[$i];
                     }
                 }
                 $fileDb = new FilfoldersFilfiles();
                 $fileDb->setFilfilesLinkedTo($fileId, $foids2);
             }
             Sydney_Db_Trace::add('trace.event.upload_file' . ' [' . $data['filename'] . ']', 'adminfiles', Sydney_Tools::getTableName($fileFile), 'uploadfile', $fileId);
             return $fileId;
         } else {
             return false;
         }
     }
 }
示例#2
0
 /**
  *
  * @param unknown_type $type
  * @param unknown_type $opts
  * @return string
  */
 private function _getQuery($type, $opts = array())
 {
     $sql = '';
     if (!is_array($opts)) {
         $opts = array($opts);
     }
     switch ($type) {
         case 'people':
             $sql = UsersOp::getSqlUserList($this->usersData, $opts);
             break;
     }
     return $sql;
 }
示例#3
0
 public function __construct($id = 0)
 {
     $this->_schema = Sydney_Tools_Sydneyglobals::getConf()->db->params->dbname;
     parent::__construct($id);
 }
示例#4
0
 /**
  * Displays the file list in an HTML format
  * URL example : http://<url>/Adminfiles/Services/displayfiles/format/json
  *
  * @return void
  */
 public function displaypeopleAction()
 {
     $r = $this->getRequest();
     $ts = 1;
     if (isset($r->vmode)) {
         $this->view->vmode = $r->vmode;
         if ($r->vmode == 'list') {
             $ts = 3;
         }
     }
     $this->view->embeded = 'no';
     $this->view->context = 'default';
     if (isset($r->embeded)) {
         $this->view->embeded = $r->embeded;
     }
     if (isset($r->context)) {
         $this->view->context = $r->context;
     }
     $this->view->files = array();
     $fltr = new Zend_Filter_Digits();
     $desc = $fltr->filter($r->desc);
     $order = $fltr->filter($r->order);
     $count = $fltr->filter($r->count);
     $offset = $fltr->filter($r->offset);
     $filter = $fltr->filter($r->filter);
     $fcompany = $fltr->filter($r->fcompany);
     $fgroup = $fltr->filter($r->fgroup);
     $fstatus = $fltr->filter($r->fstatus);
     $fltr = new Zend_Filter_Alnum();
     $searchstr = $fltr->filter($r->searchstr);
     // GDE - #52-Ajouts exports CSV - 07/08/2013
     // On enregistre les filtres afin de pouvoir les utiliser lors de l'export
     $registry = new Zend_Session_Namespace('registry-people');
     if (!$this->isCsv()) {
         $registry->peopleFilterCompany = $fcompany;
         $registry->peopleFilterGroup = $fgroup;
         $registry->peopleFilterStatus = $fstatus;
         $registry->searchstr = $searchstr;
     } else {
         $fcompany = $registry->peopleFilterCompany;
         $fgroup = $registry->peopleFilterGroup;
         $fstatus = $registry->peopleFilterStatus;
         $searchstr = $registry->searchstr;
     }
     if (isset($r->embeded)) {
         $this->view->embeded = $r->embeded;
     }
     if (isset($r->context)) {
         $this->view->context = $r->context;
     }
     // define filters
     $filters = '';
     if (isset($searchstr)) {
         $filters .= " AND ( (LOWER( CONCAT(users.fname, ' ', users.lname)) LIKE '%" . addslashes(strtolower($searchstr)) . "%') OR login like '%" . addslashes(strtolower($searchstr)) . "%' ) ";
     }
     if (isset($r->fgroup) && trim($fgroup) != '') {
         $filters .= " AND users.usersgroups_id = {$fgroup} ";
     }
     if (isset($r->fstatus) && trim($fstatus) != '') {
         $filters .= " AND users.active = {$fstatus} ";
     }
     if (isset($r->fcompany)) {
         if ($r->fcompany != '') {
             $filters .= " AND companies.id = '" . addslashes($r->fcompany) . "' ";
         }
     }
     // GDE - #52-Ajouts exports CSV - 07/08/2013
     // On d�sactive la limitation du nombre de r�sultats pour l'export csv
     if ($this->isCsv()) {
         $count = 0;
     }
     $sql = UsersOp::getSqlUserList($this->usersData, array($filters, $order, $count, $offset, $fcompany, $fgroup, $searchstr));
     $sqlCount = UsersOp::getSqlUserList($this->usersData, array($filters, $order, $count, $offset, $fcompany, $fgroup, $searchstr), true);
     $this->view->users_id = $this->usersId;
     $this->view->people = $this->_db->fetchAll($sql);
     //$where, $order, $count, $offset
     // 	sets the number of pages
     if (!$this->isCsv()) {
         $resultCount = $this->_db->fetchAll($sqlCount);
         $this->view->nbpages = ceil($resultCount[0]['cnt'] / $count);
     }
 }