Exemplo n.º 1
0
 private static function getLogger()
 {
     if (!is_object(self::$logger)) {
         self::$logger = new Sydney_Log();
         self::$logger->addWriter(new Zend_Log_Writer_Db(Zend_Registry::getInstance()->get('db'), 'safactivitylog', array('timestamp' => 'timestamp', 'priorityName' => 'priorityName', 'priority' => 'priority', 'message' => 'message', 'users_id' => 'users_id', 'login' => 'login', 'fname' => 'fname', 'lname' => 'lname', 'module' => 'module', 'action' => 'action', 'module_table' => 'module_table', 'module_ids' => 'module_ids', 'parent_id' => 'parent_id', 'safinstances_id' => 'safinstances_id')));
     }
     return self::$logger;
 }
Exemplo n.º 2
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;
         }
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 /**
  *
  */
 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);
 }
Exemplo n.º 5
0
 public function duplicateAction()
 {
     $dbId = $this->_getParam('id', null);
     $request = $this->getRequest();
     $status = 0;
     if (null == $dbId) {
         $msg = 'A problem occur.';
     } else {
         if ('pages' == $this->eModule) {
             // Soucis : il faudrait récuperer l'ordre du type de contenu
             $result = Pagdivspage::duplicate($dbId, $request->pagstructureid);
             $traceMsg = 'trace.event.duplicate_content_pages';
         } else {
             $result = Pagdivsnews::duplicate($dbId, $request->pagstructureid);
             $traceMsg = 'trace.event.duplicate_content_news';
         }
         if (false == $result) {
             $msg = 'Unknow status';
         } else {
             $msg = 'Element ' . $result;
             $status = 1;
             Sydney_Db_Trace::add($traceMsg, $request->getModuleName(), 'pagdivs', $request->getActionName(), $result, $request->pagstructureid);
         }
     }
     $this->view->ResultSet = array('message' => $msg, 'status' => $status, 'dbid' => $result, 'modal' => false);
 }
Exemplo n.º 6
0
 /**
  * Standard email form for all webinstances
  * @since 23 aug 2013
  */
 public function emailAction()
 {
     $r = $this->getRequest();
     $form = new PubcontactFormOp(null, $r->getParams());
     $form->setMethod('post');
     $purl = $this->_buildUrlFromParams($r->getParams());
     if ($purl === '') {
         $purl = '/publicms/forms/email/';
     }
     $currentLangCode = $this->getCurrentLangCode();
     $purl .= !empty($currentLangCode) ? '?slang=' . $currentLangCode : '';
     $purl .= '#pubcontact';
     $form->setAction($purl);
     if ($r->isPost()) {
         $p = $this->_flattenForemailForm($r->getParams());
         $form->populate($p);
         if ($form->isValid($p)) {
             $db = new Pubcontact();
             $dbRow = $db->createRow();
             // $dbRow->id = '';
             $dbRow->safinstances_id = Sydney_Tools_Sydneyglobals::getSafinstancesId();
             $dbRow->datetime = date('Y-m-d H:i:s');
             // $dbRow->timestamp = '';
             if (isset($p['fname'])) {
                 $dbRow->fname = $p['fname'];
             }
             if (isset($p['lname'])) {
                 $dbRow->lname = $p['lname'];
             }
             if (isset($p['fullname'])) {
                 $dbRow->fullname = $p['fullname'];
             }
             if (isset($p['email'])) {
                 $dbRow->email = $p['email'];
             }
             if (isset($p['phonenr'])) {
                 $dbRow->phonenr = $p['phonenr'];
             }
             if (isset($p['subject'])) {
                 $dbRow->subject = $p['subject'];
             }
             if (isset($p['message'])) {
                 $dbRow->message = $p['message'];
             }
             if (isset($p['subsnewsletter'])) {
                 $dbRow->subsnewsletter = $p['subsnewsletter'];
             }
             // upload the file if any
             $dbRow->filfiles_id = 0;
             if (isset($p['MAX_FILE_SIZE'])) {
                 if ($form->uploadfile->receive()) {
                     $filefilesDb = new FilfilesOp();
                     $fileData = $filefilesDb->fileToFileManager($form->uploadfile->getFileName(), date('d/m/Y H:i:s') . ' file uploaded from FORMMAIL - Author : ' . $dbRow->fname . ' ' . $dbRow->lname . ' ' . $dbRow->fullname, 'Formmail');
                     $dbRow->filfiles_id = $fileData;
                 } else {
                     Zend_Debug::dump('ERROR: The file could not be uploaded...');
                 }
             }
             $entId = $dbRow->save();
             if ($entId !== false) {
                 $this->view->confirmSent = true;
                 $this->view->form = Sydney_Tools_Localization::_('Thanks, your message has been sent.');
                 // send the mail
                 if ($this->_sendEmailForms($p['emails'], $dbRow)) {
                     Sydney_Db_Trace::add('trace.event.emailsent_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId);
                 } else {
                     Sydney_Db_Trace::add('trace.event.emailerror_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId);
                 }
             } else {
                 $this->view->form = $form;
             }
         } else {
             $this->view->form = $form;
         }
     } else {
         $this->view->form = $form;
     }
 }
Exemplo n.º 7
0
 /**
  * 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);
 }