/** * 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; } } }
public function restoreAction() { $this->view->ResultSet = array('message' => 'Node not restored !', 'status' => 0, 'modal' => true); $data = Zend_Json::decode($this->getRequest()->jsondata); try { if ($data['dbId'] > 0) { // restore node $pgsd = new Pagstructure(); $node = $pgsd->get($data['dbId']); $pgsd->restoreNode($data['dbId']); /* * GDE : 27/08/2010 * Add trace of current action */ Sydney_Db_Trace::add('trace.event.restore_page' . ' [' . $node->label . ']', 'adminpages', Sydney_Tools::getTableName($pgsd), 'restorepage', $data['dbId']); // */ $this->view->ResultSet = array('message' => 'Node restored !', 'status' => 1, 'modal' => false); } else { $this->view->ResultSet = array('message' => 'Node not found !', 'status' => 0, 'modal' => true); } } catch (Exception $e) { $this->view->ResultSet = array('message' => 'error! ' . $e->getMessage(), 'status' => 0, 'modal' => true); } }
/** * */ public function editadvancedprocessAction() { $r = $this->getRequest(); $eid = 0; if ($r->id > 0) { $nodeDB = new Pagstructure(); $node = $nodeDB->fetchRow('id = ' . $r->id . ' AND safinstances_id = ' . $this->safinstancesId); $node->metakeywords = $r->metakeywords; $node->metadesc = $r->metadesc; $node->iscachable = $r->iscachable; $node->cachetime = $r->cachetime; $node->redirecttoid = $r->redirecttoid; $node->shortdesc = $r->shortdesc; $node->colorcode = $r->colorcode; $node->layout = $r->layout; $node->save(); $eid = $r->id; // GDE : 27/08/2010 - Add trace of current action Sydney_Db_Trace::add('trace.event.update_advanced_properties' . ' [' . $node->label . ']', 'adminpages', Sydney_Tools::getTableName($nodeDB), 'editadvancedproperties', $eid); } // update the linked menu $mns = new PagstructurePagmenus(); $mns->delete('pagstructure_id = ' . $eid); //Zend_Debug::dump($r->menus); if (is_array($r->menus)) { foreach ($r->menus as $mid) { $crow = $mns->createRow(); $crow->pagstructure_id = $eid; $crow->pagmenus_id = $mid; $crow->save(); } } PagstructureOp::cleanCache($this->safinstancesId); $this->redirect('/adminpages/pages/edit/id/' . $eid); }
/** * Unpublish a div (set a div as draft) * */ public function unpublishdivAction() { $dbId = 0; $msg = 'Unknown status'; $request = $this->getRequest(); if ('pages' == $this->eModule) { $divs = new Pagdivspage(); $traceMsg = 'trace.event.update_content_pages'; } else { $divs = new Pagdivsnews(); $traceMsg = 'trace.event.update_content_news'; } $status = 0; if ($divs->checkRightFromId($request->id, $this->_config->db->safinstances_id, $this->eModule) || $request->id > 0) { $dbId = $request->id; $div = $divs->fetchRow('id=' . $request->id); $div->datemodified = new Zend_Db_Expr("NOW()"); $div->status = 'draft'; $div->params_draft = $div->params; // $div->params=null; $div->content_draft = $div->content; // $div->content=null; $div->save(); $status = 1; $msg = 'Content element save as draft'; Sydney_Db_Trace::add($traceMsg, $request->getModuleName(), Sydney_Tools::getTableName($div), $request->getActionName(), $div->id, $request->pagstructureid); } $this->view->ResultSet = array('message' => $msg, 'status' => $status, 'dbid' => $dbId, 'modal' => false); }
/** * * delete all contents of page $pageid * @param $pageId id of the pagstructure * @param $rollback determine if the content are deleted or restored */ public function deleteContentFromPage($pageId, $rollback = false) { // search all content from page $PageDiv = new PagstructurePagdivs(); $selector = $PageDiv->select()->from(Sydney_Tools::getTableName($PageDiv), 'pagdivs_id')->where('pagstructure_id = ' . $pageId); $rowset = $PageDiv->fetchAll($selector)->toArray(); $listContentId = Sydney_Tools::implode(',', $rowset); // delete content if (!empty($listContentId)) { if ($this->isLogicalDelete()) { return $this->update(array('isDeleted' => !$rollback), 'id IN (' . $listContentId . ')'); } else { return $this->delete('id IN (' . $listContentId . ')'); } } return false; }
/** * Saves the files properties. * This is called from jquery.fileproperties method save() * @return void */ public function savefilepropsAction() { $message = 'No action taken'; $fltr = new Zend_Filter_Digits(); $r = $this->getRequest(); $fid = 0; if (isset($r->fid)) { $fid = $fltr->filter($r->fid); } if ($fid > 0) { $fildb = new Filfiles(); $where = "id = {$fid} AND safinstances_id = '" . $this->safinstancesId . "'"; $rows = $fildb->fetchAll($where); if (count($rows) == 1) { if (isset($r->filename)) { $rows[0]->label = $r->filename; } if (isset($r->desc)) { $rows[0]->desc = $r->desc; } $rows[0]->istagged = 0; /** if (isset($r->istagged)) { * if ($r->istagged == 'true' )$rows[0]->istagged = 1; * } **/ $rows[0]->save(); $message = 'File params saved'; /** * GDE : 27/08/2010 * Add trace of current action */ Sydney_Db_Trace::add('trace.event.update_file' . ' [' . $r->filename . ']', 'adminfiles', Sydney_Tools::getTableName($fildb), 'updatefile', $fid); // */ // save the folders if (isset($r->filfolders) && $r->filfolders != '') { $ffdata = array(); foreach (Zend_Json::decode($r->filfolders) as $fel) { $ffdata[] = $fel['val']; } $fileFilesDb = new FilfoldersFilfiles(); $fileFilesDb->setFilfilesLinkedTo($fid, $ffdata); } } } $this->view->ResultSet = array('message' => $message); }