Beispiel #1
0
 /**
  *
  * @param $pid
  * @param $safinstancesId
  * @param int $fileFilesId
  * @param null $checked
  * @param null $usersId
  * @return array|bool
  */
 public function getMultiArrayRelations($pid, $safinstancesId, $fileFilesId = 0, $checked = null, $usersId = null)
 {
     if ($this->cacheStructureArray) {
         $cache = Zend_Registry::get('cache');
     }
     $cacheName = 'FilfoldersOp_getMultiArrayRelations_' . $pid . '_' . $safinstancesId . '_' . $fileFilesId;
     if ($this->cacheStructureArray) {
         $toReturn = $cache->load($cacheName);
     } else {
         $toReturn = false;
     }
     if (!$toReturn) {
         $where = ' safinstances_id = ' . $safinstancesId . ' ';
         $refs = array();
         $list = array();
         foreach ($this->fetchAll($where, 'pagorder') as $f) {
             $data = $f->toArray();
             $thisRef =& $refs[$data['id']];
             $thisRef['parent_id'] = $data['parent_id'];
             $thisRef['label'] = $data['label'];
             $thisRef['id'] = $data['id'];
             $thisRef['isnode'] = $data['isnode'];
             $thisRef['pagorder'] = $data['pagorder'];
             $thisRef['checked'] = false;
             $thisRef['statval'] = 0;
             if ($usersId != null) {
                 $thisRef['statval'] = $this->getstatvalq($data['id'], $usersId);
             }
             if (is_array($checked) && in_array($data['id'], $checked)) {
                 $thisRef['checked'] = true;
             }
             if ($fileFilesId > 0) {
                 $foldersDb = new FilfoldersFilfiles();
                 $where = 'filfolders_id = ' . $data['id'] . ' AND filfiles_id = ' . $fileFilesId . ' ';
                 if (count($foldersDb->fetchAll($where)) == 1) {
                     $thisRef['checked'] = true;
                 }
             }
             if ($data['parent_id'] <= 0) {
                 $list[$data['id']] =& $thisRef;
             } else {
                 $refs[$data['parent_id']]['children'][$data['id']] =& $thisRef;
             }
         }
         if ($pid > 0 && isset($list[$pid]) && isset($list[$pid]['children'])) {
             $toReturn = $list[$pid]['children'];
         } else {
             $toReturn = $list;
         }
         if ($this->cacheStructureArray) {
             $cache->save($toReturn, $cacheName);
         }
     }
     return $toReturn;
 }
 /**
  *
  * url: /admin/servicesfolder/link-filfiles-to-folder/format/json/
  * @return void
  */
 public function linkFilfilesToFolderAction()
 {
     /*
      * $this->fileid: 6406
      * $this->jsonstr:(
      * 				[0] => structure_871
      * 			    [1] => structure_3026
      * 			)
      **/
     array_walk($this->jsonstr, create_function('&$v,$k', '$v = str_replace("structure_","",$v);'));
     $oLinkFolder = new FilfoldersFilfiles();
     $oLinkFolder->setFilfilesLinkedTo($this->fileid, $this->jsonstr);
     $this->_setDataMsg('OK, link recorded', 1);
 }
Beispiel #3
0
    /**
     * Helper main function
     * @param $actionsHtml String HTML code showing the action buttons
     * @param $content String The content of this element
     * @param $dbId Int DB id of the object
     * @param $order Int order of this item in the DB
     * @param $params Array parameters (if any)
     * @return String HTML to be inserted in the view
     */
    public function ContentFile($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array('level' => 1), $moduleName = 'adminpages', $pagstructureId = 0, $sharedInIds = '')
    {
        $eventsInfo = SafactivitylogOp::getAuthorNLastEditorForContent($dbId, $moduleName);
        $module = 'publicms';
        $params2 = array('mode' => 'filids', 'layout' => 'none', 'viewl' => 'list', 'noviewswitch' => 'Y', 'ids' => $content);
        $this->view->flist = array();
        $sql = '';
        $fltr = new Zend_Filter_Digits();
        if ($params2['mode'] == 'filids' && isset($params2['ids'])) {
            $ids = array();
            foreach (explode(',', $params2['ids']) as $id) {
                $ids[] = $fltr->filter($id);
            }
        }
        if (is_array($params) && isset($params['type']) && $params['type'] == "categories") {
            // Load the files id based on their category
            $linkedFiles = new FilfoldersFilfiles();
            $ids = array();
            foreach (preg_split('/,/', $content) as $category) {
                $ids[] = $linkedFiles->getFilfilesLinkedTo($category);
            }
        }
        $this->view->viewl = 'list';
        $this->view->noviewswitch = 'Y';
        $oFile = new Filfiles();
        $params2['flist'] = $oFile->getFileInfosByIdList($ids);
        $toret = '<li
                    class="' . $params['addClass'] . ' sydney_editor_li"
                    dbparams="' . $content . '"
                    type=""
                    editclass="files"
                    dbid="' . $dbId . '"
                    dborder="' . $order . '"
                    data-content-type="file-block"
                    pagstructureid="' . $pagstructureId . '"
                    sharedinids="' . $sharedInIds . '">
		' . $actionsHtml . '
			<div class="content">
				' . $this->view->partial('file/filelist.phtml', $module, $params2) . '
			</div>
			<p class="lastUpdatedContent sydney_editor_p">' . $eventsInfo['firstEvent'] . '<br />' . $eventsInfo['lastEvent'] . '</p>
		</li>';
        return $toret;
    }
Beispiel #4
0
 /**
  *
  * @todo TODO check the security here
  * @return void
  */
 public function viewfolercontentAction()
 {
     $this->view->ajaxurl .= 'viewfolercontent/';
     $ftype = false;
     $folderIds = false;
     $filesIds = array();
     $this->view->vmode = 'list';
     $r = $this->getRequest();
     if (isset($r->vmode)) {
         $this->view->vmode = $r->vmode;
     }
     if (isset($r->paperexecpt)) {
         $this->view->paperexecpt = $r->paperexecpt;
     }
     if (isset($r->ajsrt)) {
         $this->view->ajsrt = $r->ajsrt;
     }
     if (isset($r->fids)) {
         $folderIds = preg_split('/,/', $r->fids);
         foreach ($folderIds as $fid) {
             if (preg_match('/^[0-9]{1,90}$/', $fid)) {
                 $corDB = new FilfoldersFilfiles();
                 $tempArray = array_merge($filesIds, $corDB->getFilfilesLinkedTo($fid));
                 $filesIds = $tempArray;
             }
         }
         $filsDB = new Filfiles();
         if (sizeof($filesIds) > 0) {
             $files = $filsDB->fetchAll("id IN (" . implode(',', $filesIds) . ") ", null, "datecreated DESC");
         } else {
             $files = array();
         }
         if (isset($r->format) && $r->format == 'json') {
             $this->view->files = $files->toArray();
         } else {
             $this->view->files = $files;
         }
     }
 }
Beispiel #5
0
 /**
  *
  * @return void
  */
 public function filelistAction()
 {
     $this->view->ajaxurl = '/publicms/file/filelist/';
     $request = $this->getRequest();
     $way = 'DESC';
     $srchstr = '';
     $dorder = 'datecreated';
     if (isset($request->srchstr) && $request->srchstr != '') {
         $srchstr = trim($request->srchstr);
     }
     $this->view->srchstr = $srchstr;
     $this->view->showOverlay = $request->getParam('overlay', true);
     $this->view->ajsrt = 'label';
     if (isset($request->ajsrt)) {
         // $this->view->ajsrt = $r->ajsrt;
         // $this->view->ajaxurl .= 'ajsrt/'.$this->view->ajsrt.'/';
         if ($request->ajsrt == 'date') {
             $dorder = 'filfiles.datecreated';
         }
         if ($request->ajsrt == 'label') {
             $dorder = 'filfiles.label';
         }
         if ($request->ajsrt == 'size') {
             $dorder = 'filfiles.fweight';
         }
         if ($request->ajsrt == 'user') {
             $dorder = 'u.fname,u.lname';
         }
         $this->view->ajsrt = $request->ajsrt;
     }
     if (isset($request->way)) {
         if ($request->way == 'DESC') {
             $way = '';
         }
     }
     $this->view->ajaxurl .= 'way/' . $way . '/';
     $this->view->flist = array();
     $sql = '';
     $fltr = new Zend_Filter_Digits();
     if (isset($request->id)) {
         $this->view->ajaxurl .= 'id/' . $request->id . '/';
         $folderid = $fltr->filter($request->id);
         $sql = "SELECT\n\t\t\t\t\t\tfilfiles.id,\n\t\t\t\t\t\tfilfiles.label,\n\t\t\t\t\t\tfilfiles.desc,\n\t\t\t\t\t\tfilfiles.keywords,\n\t\t\t\t\t\tfilfiles.datecreated,\n\t\t\t\t\t\tfilfiles.filename,\n\t\t\t\t\t\tfilfiles.path,\n\t\t\t\t\t\tfilfiles.type,\n\t\t\t\t\t\tu.fname,\n\t\t\t\t\t\tu.lname,\n\t\t\t\t\t\tfilfiles.fweight\n\t\t\t\t\tFROM\n\t\t\t\t\t\tfilfiles,\n\t\t\t\t\t\tfilfolders,\n\t\t\t\t\t\tfilfolders_filfiles,\n\t\t\t\t\t\tusers as u\n\t\t\t\t\tWHERE ";
         if ($srchstr != '') {
             $sql .= ' filfiles.label LIKE ' . $this->_db->quote('%' . $srchstr . '%') . ' AND ';
         }
         $sql .= "\n\t\t\t\t\t\tfilfiles.users_id = u.id AND\n\t\t\t\t\t\tfilfolders_filfiles.filfiles_id = filfiles.id AND\n\t\t\t\t\t\tfilfolders_filfiles.filfolders_id = filfolders.id AND\n\t\t\t\t\t\tfilfolders.id = '" . $folderid . "' AND\n\t\t\t\t\t\tfilfiles.safinstances_id = '" . $this->safinstancesId . "'\n\t\t\t\t\tGROUP BY filfiles.id\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\t" . $dorder . " {$way}\n\t\t\t\t\t";
     } elseif ($request->mode == 'filids' && isset($request->ids)) {
         $params = $request->params;
         if (is_string($params) && !empty($params)) {
             $params = unserialize(urldecode($params));
         }
         $ids = array();
         $this->view->ajaxurl .= 'mode/' . $request->mode . '/ids/' . $request->ids . '/params/' . urlencode(serialize($params)) . '/';
         if (isset($params) && key_exists('type', $params) && $params['type'] == "categories") {
             // Load the files id based on their category
             $linkedFiles = new FilfoldersFilfiles();
             foreach (preg_split('/,/', $request->ids) as $category) {
                 $ids[] = $linkedFiles->getFilfilesLinkedTo($category);
             }
         } else {
             foreach (explode(',', $request->ids) as $id) {
                 $ids[] = $fltr->filter($id);
             }
         }
         $oFile = new Filfiles();
         $this->view->flist = $oFile->getFileInfosByIdList($ids, explode(',', $dorder . ($way ? ' ' . $way : '')));
     }
     if (isset($request->viewl)) {
         $this->view->viewl = $r->viewl;
         $this->view->ajaxurl .= 'viewl/' . $r->viewl . '/';
     }
     if (isset($request->noviewswitch)) {
         $this->view->noviewswitch = $request->noviewswitch;
         $this->view->ajaxurl .= 'noviewswitch/' . $request->noviewswitch . '/';
     }
     if ($sql != '') {
         $this->view->flist = $this->_db->fetchAll($sql);
     }
     /**
      * Params for lightboxview
      * AS : 20 Aug. 2013
      */
     // If vtype is 'lightbox' we display the lightbox view
     if (isset($request->vtype) && $request->vtype == 'lightbox') {
         $allParams = $request->getParams();
         if (!$allParams['nbrCols']) {
             $allParams['nbrCols'] = 6;
         }
         if (!isset($allParams['thumbWidth'])) {
             $allParams['thumbWidth'] = 200;
         }
         if (!isset($allParams['fullimgWidth'])) {
             $allParams['fullimgWidth'] = 600;
         }
         if (!isset($allParams['uselightbox'])) {
             $allParams['uselightbox'] = true;
         }
         if (!isset($allParams['lfrom'])) {
             $allParams['lfrom'] = 0;
         }
         if (!isset($allParams['loffset'])) {
             $allParams['loffset'] = $allParams['nbrCols'] * 3;
         }
         if (!isset($allParams['searchtool'])) {
             $allParams['searchtool'] = true;
         }
         if (!isset($allParams['downloadable'])) {
             $allParams['downloadable'] = true;
         }
         if (isset($allParams['addClass'])) {
             unset($allParams['addClass']);
         }
         $this->view->allParams = $allParams;
         $this->render('lightbox');
     }
 }
 /**
  * Returns the folders linked to a file
  * @param int $filfilesId
  * @param boolean $json Return data in a JSON string containing the ids and labels
  * @return string
  */
 protected function _getLinkedFolders($filfilesId, $json = true)
 {
     $elements = array();
     $lDB = new FilfoldersFilfiles();
     $fDB = new Filfolders();
     $fileFilesIds = $lDB->getFilfoldersLinkedTo($filfilesId);
     if (count($fileFilesIds) > 0) {
         $sql = "id IN (" . implode(',', $fileFilesIds) . ")  ";
         foreach ($fDB->fetchAll($sql) as $el) {
             $elements[] = array('label' => addslashes($el->label), 'val' => $el->id);
         }
     }
     if ($json) {
         return preg_replace('/"/', "'", Zend_Json::encode($elements));
     } else {
         return $elements;
     }
 }
Beispiel #7
0
 /**
  * Returns an array of IDs and Names of the categories linked to this file
  * not taking into account the safinstance linked to this file
  * (this is useful for images displayed in people that can be shared trough multiple instances)
  *
  * @param $id
  * @return Array
  */
 public function getCategoriesLabels($id)
 {
     $categoryDB = new FilfoldersFilfiles();
     $foldersDb = new Filfolders();
     $idString = implode(',', $categoryDB->getFilfoldersLinkedTo($id));
     if ($idString != '') {
         $where = "id IN (" . $idString . ") ";
     } else {
         return array();
     }
     $toRetun = array();
     foreach ($foldersDb->fetchAll($where) as $element) {
         $toRetun[$element['id']] = $element['label'];
     }
     return $toRetun;
 }
Beispiel #8
0
 private function getLinkOnFolder($fileid)
 {
     // search if file has linked to a folder
     $linkedFiles = new FilfoldersFilfiles();
     return $linkedFiles->getFilfoldersLinkedTo($fileid);
 }
Beispiel #9
0
 /**
  *
  * @param unknown_type $userId
  * @param unknown_type $newAvatar
  */
 public static function changeAvatar($userId, $newAvatar = 0)
 {
     // save information into people table (users)
     $people = new Users();
     $rowPeople = $people->fetchRow("id = " . $userId);
     if (isset($rowPeople)) {
         // store old avatar
         $oldAvatar = $rowPeople->avatar;
         // update avatar
         $dataUsers = array('avatar' => $newAvatar);
         if (!$people->update($dataUsers, "id = " . $userId)) {
             return false;
         }
         // link avatar to system folder
         if ($newAvatar > 0) {
             self::linkAvatarToSystemFolder($newAvatar);
         }
         // if old avatar, check if another user has the same avatar
         if ($oldAvatar > 0) {
             // search avatar
             $select = $people->select()->where('avatar = ?', $oldAvatar);
             $rowsetPeople = $people->fetchAll($select);
             // if no avatar found, clean link between avatar and folder
             if (count($rowsetPeople) == 0) {
                 $objectFolder = new Filfolders();
                 // get id of filfolders "adminpeople" and isSystemFolder "1"
                 $rowFolder = $objectFolder->getFoldersByModule('adminpeople');
                 $objectLinkFolder = new FilfoldersFilfiles();
                 $objectLinkFolder->delete('filfiles_id = ' . $oldAvatar . ' AND filfolders_id = ' . $rowFolder->id);
             }
         }
         return true;
     }
 }