Пример #1
0
 /**
  * Returns the file types and details
  * URL example : http://<url>/adminfiles/services/getftypes/format/json
  * @return void
  */
 public function searchfileAction()
 {
     if (!empty($this->getRequest()->filename)) {
         $file = new Filfiles();
         $rowSetFiles = $file->fetchAll("filename = '" . Sydney_Medias_Utils::sanitizeFilename($this->getRequest()->filename) . "' AND safinstances_id = '" . Sydney_Tools::getSafinstancesId() . "'");
         if (count($rowSetFiles) == 1) {
             $this->view->file = $rowSetFiles[0]->id;
         } else {
             $this->view->file = 0;
         }
     } else {
         $this->view->file = 0;
     }
 }
Пример #2
0
 /**
  * @todo Change the $dbAdapter for making it automatic according to the config, here we are stuck with MySQL
  * @param Zend_Controller_Request_Http $request
  * @param bool $encryptedPass
  * @return bool|Sydney_Auth_Adaptater_DbTable
  */
 public static function getAuthAdapter(Zend_Controller_Request_Http $request, $encryptedPass = false)
 {
     // Load cookie informations
     $identity = Sydney_Http_Cookie::getIdentity($request);
     $credential = Sydney_Http_Cookie::getCredential($request);
     // Load params
     $params = $request->getParams();
     // Auth with identity and credential loaded from cookie
     if (empty($identity) && empty($credential) && empty($params['username']) && empty($params['password'])) {
         // IF no username and no password then return false
         return false;
     } elseif (!empty($identity) && !empty($credential) && empty($params['username']) && empty($params['password'])) {
         // IF identity loaded from cookie then set as params
         $params['username'] = $identity;
         $params['password'] = $credential;
     }
     $where2 = " 1 = 2 ";
     $username = strtolower(addslashes($params['username']));
     $password = addslashes($params['password']);
     // get the user if any
     $uDB = new Users();
     $users = $uDB->fetchAll(" LOWER(login) LIKE '" . $username . "' ");
     // one user found
     if (count($users) == 1) {
         if ($users[0]->safinstances_id == Sydney_Tools::getSafinstancesId()) {
             $where2 = " 1 = 1 ";
         } else {
             $corDB = new SafinstancesUsers();
             $cors = $corDB->fetchAll(" safinstances_id = " . Sydney_Tools::getSafinstancesId() . " AND users_id = " . $users[0]->id . " ");
             if (count($cors) > 0) {
                 $where2 = " 1 = 1 ";
             }
         }
         $username = $users[0]->login;
     }
     $config = Zend_Registry::get('config');
     $dbAdapter = new Zend_Db_Adapter_Pdo_Mysql($config->db->params);
     if ($encryptedPass === false) {
         $authAdapter = new Sydney_Auth_Adaptater_DbTable($dbAdapter, 'users', 'login', 'password', 'MD5(?) AND valid = 1 AND active = 1 AND (TIMESTAMPADD(SECOND,timeValidityPassword,lastpwdchanges) > now() OR timeValidityPassword = 0) AND ' . $where2);
     } else {
         $authAdapter = new Sydney_Auth_Adaptater_DbTable($dbAdapter, 'users', 'login', 'password', '? AND valid = 1 AND active = 1 AND (TIMESTAMPADD(SECOND,timeValidityPassword,lastpwdchanges) > now() OR timeValidityPassword = 0) AND ' . $where2);
     }
     // Store username and pass to cookie
     if ($params['rememberme'] == "1") {
         Sydney_Http_Cookie::setAuthCookie($username, $password, 7);
     }
     $authAdapter->setIdentity($username)->setCredential($password);
     return $authAdapter;
 }
Пример #3
0
 /**
  *
  * @param String $message
  * @param String $module
  * @param String $moduleTable
  * @param String $action
  * @param Integer $id
  * @param Integer $parentId
  */
 public static function add($message, $module, $moduleTable, $action, $id = 0, $parentId = 0)
 {
     $udata = new Zend_Session_Namespace('userdata');
     if (is_object($udata) && !empty($udata->user['users_id'])) {
         self::getLogger()->setEventItem('users_id', $udata->user['users_id']);
         self::getLogger()->setEventItem('login', $udata->user['login']);
         self::getLogger()->setEventItem('fname', $udata->user['fname']);
         self::getLogger()->setEventItem('lname', $udata->user['lname']);
     } else {
         self::getLogger()->setEventItem('users_id', 0);
         self::getLogger()->setEventItem('login', "guest");
         self::getLogger()->setEventItem('fname', "guest");
         self::getLogger()->setEventItem('lname', "anonymous");
     }
     self::getLogger()->setEventItem('module', $module);
     self::getLogger()->setEventItem('action', $action);
     self::getLogger()->setEventItem('module_table', $moduleTable);
     self::getLogger()->setEventItem('module_ids', $id);
     self::getLogger()->setEventItem('parent_id', $parentId);
     self::getLogger()->setEventItem('safinstances_id', Sydney_Tools::getSafinstancesId());
     self::getLogger()->log($message, Zend_Log::INFO);
 }
Пример #4
0
 /**
  *
  * Enter description here ...
  */
 public function countDeletedNodes()
 {
     $selector = $this->select()->where('isDeleted = 1')->where('safinstances_id = ' . Sydney_Tools::getSafinstancesId());
     return $this->fetchAll($selector)->count();
 }
Пример #5
0
 /**
  *
  */
 public function editnwsfoldersAction()
 {
     $rowId = $this->_editfieldAction('Nwsfolders', 'NwsfoldersForm', array('safinstances_id' => Sydney_Tools::getSafinstancesId()));
 }
Пример #6
0
 /**
  *
  * @param unknown_type $dbid
  * @param unknown_type $moduleName
  * @param unknown_type $moduleTable
  */
 public function getLastEvent($dbid, $moduleName, $moduleTable)
 {
     $this->selector = $this->select()->where('safinstances_id = ' . Sydney_Tools::getSafinstancesId())->where("module in ('{$moduleName}') AND module_table in ('{$moduleTable}') ")->where("module_ids REGEXP '(.*)(^|,)" . $dbid . "(,|\$)(.*)' > 0");
     $this->selector = $this->selector->order("timestamp DESC");
     $this->selector = $this->selector->limit(1);
     return $this;
 }
Пример #7
0
 private static function getCredentialCookieName()
 {
     return self::getPrefixCookieName() . sha1(Sydney_Tools::getSafinstancesId() . 'sydney_credential');
 }
Пример #8
0
 /**
  * Gets the files to be displayed in the File Manager
  *
  * @param int $typeSize
  * @param int $desc
  * @param int $order
  * @param $count
  * @param $offset
  * @param $filter
  * @param array $tagsIds
  * @param null $q
  * @param null $safinstancesId
  * @param bool $folderId
  * @return array
  */
 public function getFilesToDisplayInFM($typeSize = 1, $desc = 1, $order = 0, $count, $offset, $filter, $tagsIds = array(), $q = null, $safinstancesId = null, $folderId = false)
 {
     if ($safinstancesId == null) {
         $safinstancesId = Sydney_Tools::getSafinstancesId();
     }
     $filesToReturn = array('files' => array(), 'nbpages' => 0);
     $where = "safinstances_id = '" . $safinstancesId . "' ";
     $order = $this->orders[$order];
     if ($desc == 1) {
         $order .= ' DESC';
     }
     // set the filters
     if ($q != null) {
         $where .= " AND ( label LIKE '%" . $q . "%'\n\t\t\tOR filename LIKE '%" . $q . "%'\n\t\t\tOR `desc` LIKE '%" . $q . "%'\n\t\t\tOR keywords LIKE '%" . $q . "%'\n\t\t\tOR idxcontent  LIKE '%" . $q . "%'\n\t\t\t) ";
     }
     // taking care of the folders
     // $folderid = 5735; $folderid = 0;
     if ($folderId !== false) {
         $idsIn = $this->getIDsOfFilesInCategory($folderId, $safinstancesId);
         $filesToReturn = $this->getFoldersFiles($folderId, $safinstancesId);
         $where .= " AND id IN (" . implode(',', $idsIn) . ") ";
         // return and empty set of files if no files in the folder
         if (is_array($idsIn) && count($idsIn) == 0) {
             return $filesToReturn;
         }
     }
     // @todo: link that to a centralized area for doc type management
     $filters = Sydney_Medias_Utils::$filters;
     $where .= " AND type != 'JSON' ";
     if ($filter > 0 && $filter < 20) {
         $where .= ' AND type IN (\'' . implode("','", $filters[$filter]) . '\') ';
     }
     if (count($tagsIds) > 0) {
         $where .= ' AND id IN (SELECT filfiles_id FROM filfolders_filfiles WHERE filfolders_id IN (' . implode(",", $tagsIds) . ') ) ';
     }
     // sets the number of pages
     $filesToReturn['nbpages'] = ceil(count($this->fetchAll($where)) / $count);
     foreach ($this->fetchAll($where, $order, $count, $offset) as $file) {
         $isTagged = 0;
         $isTaggedSql = "SELECT count(*) AS cnt FROM filfolders_filfiles WHERE filfiles_id = '" . $file->id . "' ";
         $isTaggedResult = $this->_db->fetchRow($isTaggedSql);
         if ($isTaggedResult['cnt'] > 0) {
             $isTagged = 1;
         }
         $stringLenght = 10;
         $user = new Users();
         if (strlen($file->label) <= $stringLenght) {
             $fileName = $file->label;
         } else {
             $fileName = substr($file->label, 0, $stringLenght - 3) . '...';
         }
         $filesToReturn['files'][] = array('id' => $file->id, 'url' => '/adminfiles/file/thumb/id/' . $file->id . '/ts/' . $typeSize . '/fn/' . $file->id . '.png', 'name' => $fileName, 'fullname' => $file->label, 'filename' => $file->filename, 'info' => 'Uploaded by ' . $user->getUserName($file->users_id), 'date' => $file->datecreated, 'type' => $file->type, 'istagged' => $isTagged, 'filetype' => 'file', 'fweight' => $file->fweight);
     }
     return $filesToReturn;
 }
Пример #9
0
 /**
  *
  */
 protected function setAuthPagelist()
 {
     // Get list of pages secured by groups
     $listSecuredPages = array();
     $pages = new Pagstructure();
     $selector = $pages->select(false)->from($pages->getTableName(), array('id', 'usersgroups_id'))->where('safinstances_id = ?', Sydney_Tools::getSafinstancesId())->where('usersgroups_id > ?', 1);
     $rowObjectList = $pages->fetchAll($selector);
     foreach ($rowObjectList as $rowObject) {
         $listSecuredPages[$rowObject->id] = $rowObject->usersgroups_id;
     }
     Zend_Registry::set('listSecuredPages', $listSecuredPages);
 }
Пример #10
0
 /**
  * Checks if this email is a valid and authorized user for the safinstance
  * @param string $email Email
  * @param int $safinstancesId Safinstances_id
  *
  * @return boolean True if valid, false if not
  */
 public function isEmailAvalidUser($email = '', $safinstancesId = null)
 {
     if ($safinstancesId == null) {
         $safinstancesId = Sydney_Tools::getSafinstancesId();
     }
     $sql = "\n\t\t\tSELECT\n\t\t\t  count(login) AS nbrusers\n\t\t\tFROM\n\t\t\t  users LEFT JOIN safinstances_users ON safinstances_users.users_id = users.id\n\t\t\tWHERE\n\t\t\t( safinstances_users.safinstances_id = '" . $safinstancesId . "' OR\n\t\t\t  users.safinstances_id = '" . $safinstancesId . "' )\n\t\t\tAND ( users.email='" . $email . "' OR\n\t\t\t      users.login='******' )\n\t\t\tAND users.valid = 1\n\t\t\tAND users.active = 1\n\t\t";
     $result = $this->_db->fetchAll($sql);
     return count($result) > 0 && isset($result[0]['nbrusers']) && $result[0]['nbrusers'] > 0;
 }
Пример #11
0
 /**
  * Return a structured array containing categories (or folders)
  *
  * @param int $parentId From this ID
  * @param string $whereFile Optional where clause
  * @param boolean $showSystem Should we include the system category?
  * @param boolean $numberFilesPerFolders Include the number of files per folders?
  * @param int $safinstanceId The safinstance id
  * @param bool $firstCall
  * @return array
  */
 public function getFoldersStructure($parentId = 0, $whereFile = null, $showSystem = false, $numberFilesPerFolders = true, $safinstanceId = null, $firstCall = true)
 {
     $toReturn = array();
     $whereAdd = '';
     if ($safinstanceId == null) {
         $safinstanceId = Sydney_Tools::getSafinstancesId();
     }
     $whereCurrent = " id = '" . $parentId . "' AND safinstances_id = '" . $safinstanceId . "' ";
     $where = " parent_id = '" . $parentId . "' AND safinstances_id = '" . $safinstanceId . "' ";
     if (!$showSystem && $parentId == 0) {
         $whereAdd .= " AND label != 'system' ";
     } elseif (!$showSystem) {
         $whereAdd .= " AND isSystemFolder = 0 ";
     }
     if ($whereFile != null) {
         $whereAdd .= ' AND ' . $whereFile;
     }
     $toReturn = $this->fetchAll($where . $whereAdd, 'pagorder')->toArray();
     // get kids
     for ($i = 0; $i < count($toReturn); $i++) {
         if ($numberFilesPerFolders) {
             $toReturn[$i]['nbfiles'] = $this->_countFilesInFolder($toReturn[$i]['id']);
             //$nbfi += $toret[$i]['nbfiles'];
         } else {
             $toReturn[$i]['nbfiles'] = null;
         }
         $toReturn[$i]['kids'] = $this->getFoldersStructure($toReturn[$i]['id'], $whereFile, $showSystem, $numberFilesPerFolders, $safinstanceId, false);
     }
     if ($firstCall) {
         $Return[0] = array();
         if ($arol = $this->fetchRow($whereCurrent . $whereAdd)) {
             $Return[0] = $arol->toArray();
         }
         $Return[0]['nbfiles'] = $this->_countFilesInFolder($Return[0]['id']);
         $Return[0]['kids'] = $toReturn;
         return $Return;
     } else {
         return $toReturn;
     }
 }
Пример #12
0
 /**
  *
  */
 public function getDivsDraft()
 {
     $selector = $this->select()->setIntegrityCheck(false)->from('pagstructure', array('id'))->columns('count(pagstructure.id) as  cnt')->join('pagstructure_pagdivs', 'pagstructure.id = pagstructure_pagdivs.pagstructure_id', '')->join('pagdivs', 'pagdivs.id = pagstructure_pagdivs.pagdivs_id', '')->where('pagstructure.safinstances_id = ' . Sydney_Tools::getSafinstancesId())->where('pagdivs.isDeleted = 0')->where('pagdivs.content_draft != ""')->group('pagstructure.id');
     $localArray = $this->fetchAll($selector)->toArray();
     foreach ($localArray as $row) {
         $returnArray[$row['id']] = $row['cnt'];
     }
     return $returnArray;
 }