public function __construct($options = null) { parent::__construct($options); $this->setAttrib('accept-charset', 'UTF-8'); $this->setName('filfolders'); $id = new Zend_Form_Element_Hidden('id'); $hash = new Zend_Form_Element_Hash('no_csrf_foo', array('salt' => '4s564evzaSD64sf')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $label = new Zend_Form_Element_Text('label'); $label->setLabel('label'); $desc = new Zend_Form_Element_Textarea('desc'); $desc->setLabel('desc'); $parentId = new Zend_Form_Element_Select('parent_id'); $options = new Filfolders(); $parentId->addMultiOption('', '----------'); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $parentId->addMultiOption($k, $v['mlabel']); } $parentId->setLabel('parent_id'); $isnode = new Zend_Form_Element_Text('isnode'); $isnode->setLabel('isnode'); $isparam = new Zend_Form_Element_Text('isparam'); $isparam->setLabel('isparam'); $relevance = new Zend_Form_Element_Text('relevance'); $relevance->setLabel('relevance'); $pagorder = new Zend_Form_Element_Text('pagorder'); $pagorder->setLabel('pagorder'); $linkedto = new Zend_Form_Element_Textarea('linkedto'); $linkedto->setLabel('linkedto'); $isSystemFolder = new Zend_Form_Element_Text('isSystemFolder'); $isSystemFolder->setLabel('isSystemFolder'); $this->addElements(array($id, $hash, $label, $desc, $parentId, $isnode, $isparam, $relevance, $pagorder, $linkedto, $isSystemFolder)); $this->addElements(array($submit)); }
public function getUsers($tagId) { $user = new Users(); $tag = new Filfolders(); $selector = $this->select(Zend_Db_Table::SELECT_WITHOUT_FROM_PART)->setIntegrityCheck(false)->from(array('u' => $user->getTableName(true)), 'id')->join(array('fu' => $this->getTableName(true)), 'u.id = fu.users_id', '')->join(array('ff' => $tag->getTableName(true)), 'fu.filfolders_id = ff.id', '')->where('ff.id = ?', $tagId)->order('ff.pagorder'); return $this->fetchAll($selector); }
public function init() { $options = new Filfolders(); foreach ($options->fetchAlltoFlatArray() as $k => $v) { if (isset($v['mlabel'])) { $this->addMultiOption($k, $v['mlabel']); } } }
public function __construct($options = null) { parent::__construct($options); $this->setAttrib('accept-charset', 'UTF-8'); $this->setName('safmodules'); $id = new Zend_Form_Element_Hidden('id'); $hash = new Zend_Form_Element_Hash('no_csrf_foo', array('salt' => '4s564evzaSD64sf')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $label = new Zend_Form_Element_Text('label'); $label->setLabel('label'); $image = new Zend_Form_Element_Textarea('image'); $image->setLabel('image'); $description = new Zend_Form_Element_Textarea('description'); $description->setLabel('description'); $usersgroupsId = new Zend_Form_Element_Select('usersgroups_id'); $options = new Usersgroups(); $usersgroupsId->addMultiOption('', '----------'); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $usersgroupsId->addMultiOption($k, $v['mlabel']); } $usersgroupsId->setLabel('usersgroups_id'); $prefix = new Zend_Form_Element_Text('prefix'); $prefix->setLabel('prefix'); $name = new Zend_Form_Element_Text('name'); $name->setLabel('name'); $showintab = new Zend_Form_Element_Text('showintab'); $showintab->setLabel('showintab'); $istechnical = new Zend_Form_Element_Text('istechnical'); $istechnical->setLabel('istechnical'); $order = new Zend_Form_Element_Text('order'); $order->setLabel('order'); $isalwaysactive = new Zend_Form_Element_Text('isalwaysactive'); $isalwaysactive->setLabel('isalwaysactive'); $isapplication = new Zend_Form_Element_Text('isapplication'); $isapplication->setLabel('isapplication'); $longdesc = new Zend_Form_Element_Text('longdesc'); $longdesc->setLabel('longdesc'); $fileFoldersId = new Zend_Form_Element_Select('filfolders_id'); $options = new Filfolders(); $fileFoldersId->addMultiOption('', '----------'); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $fileFoldersId->addMultiOption($k, $v['mlabel']); } $fileFoldersId->setLabel('filfolders_id'); $safinstancesTypeId = new Zend_Form_Element_Select('safinstancestype_id'); $options = new Safinstancestype(); $safinstancesTypeId->addMultiOption('', '----------'); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $safinstancesTypeId->addMultiOption($k, $v['mlabel']); } $safinstancesTypeId->setLabel('safinstancestype_id'); $safinstancesSafmodules = new SafinstanceslistForm('SafinstancesSafmodules'); $safinstancesSafmodules->setLabel('SafinstancesSafmodules'); $this->addElements(array($id, $hash, $label, $image, $description, $usersgroupsId, $prefix, $name, $showintab, $istechnical, $order, $isalwaysactive, $isapplication, $longdesc, $fileFoldersId, $safinstancesTypeId, $safinstancesSafmodules)); $this->addElements(array($submit)); }
/** * */ public function indexAction() { $this->setSubtitle('Adminfiles'); $this->setSideBar('index', 'default'); $this->layout->langswitch = true; $this->layout->search = true; $flo = new Filfolders(); $this->view->list = $flo->getMultiArrayRelations(0, $this->safinstancesId); }
/** * List of the folders (tags) in an structured array (arborescence) * @return void */ public function folderslistAction() { $r = $this->getRequest(); $pid = 0; // id of the root we want to display the kids or none for all if (isset($r->parentid)) { $pid = $r->parentid; } $flo = new Filfolders(); $this->view->list = $flo->getMultiArrayRelations($pid, $this->safinstancesId); }
public function __construct($options = null) { parent::__construct($options); $this->setAttrib('accept-charset', 'UTF-8'); $this->setName('safmodules'); $id = new Zend_Form_Element_Hidden('id'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton'); $label = new Zend_Form_Element_Text('label'); $label->setLabel('label'); $image = new Zend_Form_Element_Text('image'); $image->setLabel('Picto path'); $description = new Zend_Form_Element_Textarea('description'); $description->setLabel('Description'); $usersGroupsId = new Zend_Form_Element_Select('usersgroups_id'); $options = new Usersgroups(); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $usersGroupsId->addMultiOption($k, $v['mlabel']); } $usersGroupsId->setLabel('usersgroups_id'); $prefix = new Zend_Form_Element_Text('prefix'); $prefix->setLabel('Prefix'); $name = new Zend_Form_Element_Text('name'); $name->setLabel('Technical Name'); $showintab = new Zend_Form_Element_Text('showintab'); $showintab->setLabel('Show in tab?'); $istechnical = new Zend_Form_Element_Text('istechnical'); $istechnical->setLabel('Is technical only?'); $order = new Zend_Form_Element_Text('order'); $order->setLabel('Order'); $isalwaysactive = new Zend_Form_Element_Text('isalwaysactive'); $isalwaysactive->setLabel('Is always active?'); $longdesc = new Zend_Form_Element_Textarea('longdesc'); $longdesc->setLabel('Long description'); $fileFoldersId = new Zend_Form_Element_Select('filfolders_id'); $options = new Filfolders(); $fileFoldersId->addMultiOption('', '----------'); foreach ($options->fetchAll("safinstances_id = '" . $this->safinstancesid . "' ") as $k => $v) { $fileFoldersId->addMultiOption($v->id, $v->label); } $fileFoldersId->setLabel('Image category'); $safinstancesTypeId = new Zend_Form_Element_Select('safinstancestype_id'); $options = new Safinstancestype(); $safinstancesTypeId->addMultiOption('', '----------'); foreach ($options->fetchAlltoFlatArray() as $k => $v) { $safinstancesTypeId->addMultiOption($k, $v['mlabel']); } $safinstancesTypeId->setLabel('safinstancestype_id'); $this->addElements(array($id, $label, $safinstancesTypeId, $image, $fileFoldersId, $description, $longdesc, $usersGroupsId, $prefix, $name, $showintab, $istechnical, $order, $isalwaysactive)); $this->addElements(array($submit)); }
/** * * url: /admin/servicesfolder/link-file-to-folder/format/json/ * @return void */ public function reorderfolderAction() { /* * $this->datatable * $this->fileid: 6406 * $this->jsonstr:Array ( [0] => Array ( [key] => structure_871 [position] => 1 [parent] => _1 ) [1] => Array ( [key] => structure_811 [position] => 2 [parent] => _1 ) [2] => Array ( [key] => structure_801 [position] => 3 [parent] => _1 ) ) **/ $oFolder = new Filfolders(); foreach ($this->jsonstr as $node) { $parent = $node['parent'] == '_1' ? 0 : str_replace('structure_', '', $node['parent']); $oFolder->setPosition($node['position'], str_replace('structure_', '', $node['key']), $parent); } $this->_setDataMsg('OK, order changed', 1); }
/** * Displays the upload screen * @return void */ public function uploadAction() { //$this->_helper->layout->disableLayout(); $params = $this->getRequest()->getParams(); // gets the categories for upload + tagging $catDB = new Filfolders(); $this->view->categories = $catDB->getFoldersStructure(); if ($params['calledBy'] != 'adminpeople') { $this->setSubtitle('Upload files'); $this->setSideBar('upload', 'files'); } if (count($_FILES['file']) > 0) { switch ($_FILES['file']['error']) { case UPLOAD_ERR_OK: $fullpath = Sydney_Tools::getAppdataPath() . '/adminfiles/'; $filename = $_FILES['file']['name']; $ndirn = substr($filename, -3); $ndirn = preg_replace('/\\./', '', $ndirn); $nnd = $fullpath . '/' . strtoupper($ndirn); $type = strtoupper($ndirn); if (!is_dir($nnd)) { mkdir($nnd); } if (!empty($_POST['fileupload-new-filename'])) { $filename = $_POST['fileupload-new-filename']; } if (move_uploaded_file($_FILES['file']['tmp_name'], $nnd . '/' . $filename)) { $fil = new Filfiles(); $fil->registerFileToDb($nnd, $filename, filesize($nnd . '/' . $filename), $type, $this->usersId, $this->safinstancesId, $this->getRequest()); $returnmsg = '"' . $filename . '", ' . Sydney_Tools::_('UPLOAD_ERR_OK'); } else { $returnmsg = Sydney_Tools::_('UPLOAD_UNKNOW_ERROR'); } break; case UPLOAD_ERR_INI_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_INI_SIZE'); break; case UPLOAD_ERR_FORM_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_FORM_SIZE'); break; case UPLOAD_ERR_PARTIAL: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_PARTIAL'); break; case UPLOAD_ERR_NO_FILE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_FILE'); break; case UPLOAD_ERR_NO_TMP_DIR: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_TMP_DIR'); break; case UPLOAD_ERR_CANT_WRITE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_CANT_WRITE'); break; case UPLOAD_ERR_EXTENSION: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_EXTENSION'); break; } if (!empty($returnmsg)) { echo '<span class="warning">', $returnmsg, '</span>'; } } }
/** * */ public function updatefilfoldersAction() { $sDB = new Filfolders(); $this->view->result = $sDB->updateOneField($this->getRequest()->getPost()); }
/** * 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; } }
/** * 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; }
/** * * @return void */ public function deleteAction() { $id = (int) $this->_request->getParam('id'); if ($id > 0) { $fileFolders = new Filfolders(); $where = 'id = ' . $id; $fileFolders->delete($where); } $this->redirect('/adminfiles/filfolders/index'); }
/** * * @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; } }