/** * * @param unknown_type $object */ public static function getTableName($object) { if (is_object($object)) { if (get_class($object) == 'Zend_Db_Table_Row') { return $object->getTable()->info('name'); } elseif (method_exists($object, 'info')) { $info = $object->info(); return $info['name']; } } return Sydney_Tools::_('unknow_table'); }
/** * Helper main function * @return String HTML to be inserted in the view * @param Array $structureArray [optional] Structure in an array form */ public function Dashboard($listactivities) { $html = ''; foreach ($listactivities['time'] as $datetime => $activityListId) { $html .= '<div xmlns="http://www.w3.org/1999/xhtml" class="whitebox"> <h2>' . $datetime . '</h2><ul class="journal">'; foreach ($activityListId as $activityId) { $html .= '<li> ' . Sydney_Tools::getTime($listactivities['datas'][$activityId]->timestamp) . ': '; switch ($listactivities['datas'][$activityId]->module . '-' . $listactivities['datas'][$activityId]->module_table . '-' . $listactivities['datas'][$activityId]->action) { case 'adminfiles-filfiles-insert': case 'adminfiles-filfiles-update': $html .= '<a href="/adminfiles/index/index/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminpages-pagstructure-restore': case 'adminpages-pagstructure-insert': case 'adminpages-pagstructure-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/index/edit/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminpages-pagdivs-insert': case 'adminpages-pagdivs-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/pages/edit/id/' . $listactivities['datas'][$activityId]->parent_id . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminnews-nwsnews-insert': case 'adminnews-nwsnews-update': $html .= '<a href="/' . $listactivities['datas'][$activityId]->module . '/index/properties/id/' . $listactivities['datas'][$activityId]->module_ids . '">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; case 'adminnews-pagdivs-insert': case 'adminnews-pagdivs-update': $html .= '<a href="/adminpages/pages/edit/id/' . $listactivities['datas'][$activityId]->parent_id . '/emodule/news">' . $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action) . ' </a>'; break; default: $html .= $listactivities['datas'][$activityId]->cnt . ' ' . Sydney_Tools::_('trace.event.action.' . $listactivities['datas'][$activityId]->action); break; } $html .= ' <strong>by</strong> ' . $listactivities['datas'][$activityId]->fname . ' ' . $listactivities['datas'][$activityId]->lname . '. </li>'; } $html .= '</ul></div>'; } return $html; }
public function processuserAction() { $data = $this->getRequest()->getPost(); $objectUser = new Users(); if (!($this->view->status = $objectUser->save($data, true))) { $msg = Sydney_Messages::getInstance()->getMessages(); $this->view->message = 'Validation errors found...'; if (!is_array($msg)) { $this->view->message .= ' (' . $msg . ')'; } $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => array()); } else { // send email if (!$objectUser->isEditMode($data)) { $data['id'] = $objectUser->get()->id; $mailSubject = str_replace('[SITE_TITLE]', Sydney_Tools::getConf('general')->siteTitle, Sydney_Tools::_('subjectMailSubscribe')); $objectUser->registermail($objectUser->get()->login, $mailSubject, $data, $confirmationAction = '/publicms/profile/confirm/init/2', false, array('management/partialmailconfirm.phtml', 'publictimedex')); } $this->view->message = Sydney_Messages::getInstance()->getMessages(); $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => $objectUser->get()->toArray()); } $this->view->showtime = 3; $this->view->modal = false; }
/** * Returns the login form * @return Sydney_Form */ private function getLoginForm($renewalPassword = false) { $r = $this->getRequest(); if (isset($r->redirectmodule)) { $action = '/default/login/process/redirectmodule/' . $r->getParam('redirectmodule', 'admindashboard'); } elseif (isset($r->redirectpage)) { $action = '/default/login/process/redirectpage/' . $r->redirectpage; } elseif (substr($r->module, 0, 5) == 'admin') { $module = $r->module; if ('admin' == $module) { $module = 'admindashboard'; } $this->setLayoutLoginAdmin(); $action = '/default/login/process/redirectmodule/' . $module; } elseif (null != $r->getParam('page', null)) { $action = '/default/login/process/redirectpage/' . $r->getParam('page'); } else { $action = '/default/login/process/'; } $config = new Zend_Config_Ini(__DIR__ . '/../config/default.login.index.ini', 'loginform'); $form = new Sydney_Form($config); $form->setAction($action); // Set decorator to checkbox element 'Remember Me' $form->addPrefixPath('Sydney_Decorator', 'Sydney/Decorator/', 'decorator'); $form->addElementPrefixPath('Sydney_Decorator', 'Sydney/Decorator/', 'decorator'); $form->getElement('rememberme')->setDecorators(array('CheckboxloginDecorator')); /**/ // Check concurrent access // if params MaxLogin exist then check the number of session $this->view->maxLoginExceeded = false; if ($renewalPassword) { $form->setDescription(Sydney_Tools::_('Your password has expired. Please change it!')); // clone submit $submit = clone $form->getElement('submit'); $form->removeElement('submit'); // clone remember me $rememberme = clone $form->getElement('rememberme'); $form->removeElement('rememberme'); // clone password $newPassword = clone $form->getElement('password'); $newPassword->setName('new_password'); $newPassword->setLabel('New password'); // clone password2 $confirmNewPassword = clone $form->getElement('password'); $confirmNewPassword->setName('confirm_new_password'); $confirmNewPassword->setLabel('Confirm new password'); $form->addElements(array($newPassword, $confirmNewPassword, $rememberme, $submit)); } return $form; }
/** * 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>'; } } }
/** * Deletes a DIV from the DB * * @return void */ public function deletedivAction() { $divs = new Pagdivspage(); $request = $this->getRequest(); $status = 0; if (!$request->id) { $msg = 'Ok'; $status = 1; } else { /* * Get detail for Add trace of current action */ if ($this->eModule == 'pages') { $orderPageDiv = new Pagdivspage($request->id); $rowPage = $orderPageDiv->getParent(); $parentId = $rowPage->get()->id; $orderPage = new Pagstructure(); $orderPage->saveLastupdateContent($parentId); $module = 'adminpages'; $traceMessage = Sydney_Tools::_('trace.event.delete_content_page') . ' [' . $rowPage->get()->label . ']'; } if ($request->id <= 0) { $msg = 'Technical error. The entry ID has an inconcistent value!'; $status = 0; } elseif ($this->eModule == 'pages' && $divs->checkRightFromId($request->id, $this->_config->db->safinstances_id)) { $divs->delete('id = ' . $request->id); $msg = 'Element deleted.'; $status = 1; } else { // @todo TODO : quick fix here to make deletable work for news but we do not check the access rights anymore... it is a problem $divs->delete('id = ' . $request->id); $msg = 'Element deleted.'; $status = 1; } if ($status == 1) { /* * Add trace of current action */ Sydney_Db_Trace::add($traceMessage, $module, Sydney_Tools::getTableName($divs), 'deletecontent', $request->id, $parentId); } } $this->view->ResultSet = array('message' => $msg, 'status' => $status, 'dbid' => $request->id, 'modal' => false); }
private function saveRow($data, $modeEdit, $isPublicModule) { try { $usersDb = new Users(); if ($modeEdit) { $rows = $usersDb->fetchAll(" id = '" . $data['id'] . "' AND login = '******'login']) . "' "); $row = $rows[0]; } else { $row = $usersDb->createRow(); } // Store row $this->set($row); foreach ($data as $k => $v) { if (isset($data[$k]) && isset($row->{$k})) { switch ($k) { case 'password': if (!empty($data[$k])) { if (!$this->isValidPassword($data[$k], $data['id'])) { Sydney_Messages::getInstance()->addMessage(Sydney_Tools::_('Please use another password!')); return false; } $row->lastpwdhistory = $this->getUpdatedHistoryForDb($row->lastpwdhistory, $data[$k]); $row->{$k} = md5($data[$k]); $row->lastpwdchanges = Sydney_Tools::getMySQLFormatedDate(); $row->timeValidityPassword = 0; } break; case 'valid': if ($row->{$k} != $data[$k]) { $row->laststatuschange = Sydney_Tools::getMySQLFormatedDate(); if ($row->{$k} == 1) { $row->unsubscribedate = Sydney_Tools::getMySQLFormatedDate(); } } $row->{$k} = $data[$k]; break; case 'active': if ($row->{$k} != $data[$k]) { $row->laststatuschange = Sydney_Tools::getMySQLFormatedDate(); if ($row->{$k} == 1) { $row->unsubscribedate = Sydney_Tools::getMySQLFormatedDate(); } } $row->{$k} = $data[$k]; break; default: $row->{$k} = $data[$k]; break; } } } $creation = !($row->id > 0); // Store row $this->set($row); if (!$creation) { // in case we are editing $row->modifieddate = Sydney_Tools::getMySQLFormatedDate(); } else { // fixed values if public creation if ($isPublicModule) { $row->usersgroups_id = 2; // User is added to group 'auth' $row->active = 0; // User is not active } // in case we are creating $usersData = Sydney_Tools::getUserdata(); $row->subscribedate = Sydney_Tools::getMySQLFormatedDate(); $row->modifieddate = Sydney_Tools::getMySQLFormatedDate(); $row->safinstances_id = Sydney_Tools::getSafinstancesId(); $row->creatoridentity = $usersData ? $usersData['users_id'] : 0; $row->ip = $_SERVER['REMOTE_ADDR']; } if ($newId = $row->save()) { Sydney_Messages::getInstance()->addMessage('Success! The data is valid.'); $row->id = $newId; // Store row $this->set($row); if ($creation) { // create the link to cor table $corDb = new SafinstancesUsers(); $corRow = $corDb->createRow(); $corRow->safinstances_id = Sydney_Tools::getSafinstancesId(); $corRow->users_id = $row->id; $corRow->save(); } return $row; } else { Sydney_Messages::getInstance()->addMessage('Error...'); return false; } } catch (Exception $e) { Sydney_Messages::getInstance()->addMessage('UsersOp::save::Exception! ' . $e->getMessage()); return false; } }