Exemple #1
0
 /**
  * Generate local actions View.
  *
  * @static
  * @access   public
  * @return   View
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function generateActions()
 {
     $aActions = [];
     $sForRoute = Router::getCurrentRouteName();
     $aLocalActions = static::getLocalActions($sForRoute);
     // create local actions
     foreach ($aLocalActions as $oAction) {
         /* @var $oAction LocalActions\Action */
         // check conditions
         $aConditions = $oAction->getConditions();
         $oBuilder = $oAction->getBuilder();
         $aParams = $oAction->getParameters();
         if (!empty($aConditions)) {
             foreach ($oAction->getConditions() as $sParam => $sParamValue) {
                 if (Router::getParam($sParam) != $sParamValue) {
                     continue 2;
                 }
             }
         }
         // get route and check access to it
         $oRoute = Route::factory($oAction->getRoute());
         if ($oRoute->hasAccess($aParams) === FALSE) {
             continue 1;
         }
         // use builder, if set
         if ($oBuilder !== NULL) {
             $oBuilder($oAction);
         }
         // create new local action
         $sURL = $oRoute->url($oAction->getParameters());
         $aActions[] = ['url' => $sURL, 'title' => $oAction->getTitle(), 'icon' => $oAction->getIcon()];
     }
     return View::factory('base/local_actions')->bind('aActions', $aActions);
 }
Exemple #2
0
 /**
  * Activate user account.
  *
  * @access     public
  * @return     View
  * @since      1.0.0
  * @version    1.1.0, 2015-02-12
  */
 public function actionActivation()
 {
     // if user is logged, redirect to main page
     if (UserModel::isLogged()) {
         Route::factory('home')->redirectTo();
     }
     // set page title
     $this->setTitle(__('Activate your new account'));
     // get code from URL
     $sCode = Router::getParam('code');
     $bActivated = FALSE;
     // get activation code from DB
     $oResult = DB::query("SELECT c FROM \\Model\\User\\ActivationCode c WHERE c.code = :code")->param('code', $sCode)->single();
     /* @var $oResult ActivationCodeModel */
     // activate user
     if ($oResult instanceof ActivationCodeModel) {
         // Set user as activated
         $bActivated = TRUE;
         $oUser = $oResult->getUser();
         $oUser->setActivation(TRUE);
         DB::flush();
         // Remove activation code from DB
         DB::remove($oResult);
         DB::flush();
     }
     // view
     return View::factory("user/frontend/register/activation")->bind('bActivated', $bActivated);
 }
Exemple #3
0
 /**
  * ACTION - Backend delete action.
  *
  * @access   public
  * @return   View
  * @since    2.1.2-dev
  * @version  2.1.2-dev
  */
 public function actionDelete()
 {
     // check if someone want to remove admin account
     if ((int) Router::getParam('id') === 1) {
         return View::factory('base/alert')->set('sType', 'danger')->set('sMsg', __('Admin account cannot be removed!'));
     }
     // return View
     return parent::actionDelete();
 }
 /**
  * Default action for TinyMCE Responsive File Manager. Config file available
  * via <code>\ResponsiveFileManager::$aConfig</code> variable. For 
  * non-commercial usage only.
  * 
  * @access	public
  * @since	1.0.0-dev
  * @version	1.0.1
  */
 public function actionDefault()
 {
     $sFileManagerAction = Router::getParam('fmaction');
     if (!in_array($sFileManagerAction, ['dialog', 'ajax_calls', 'execute', 'force_download', 'upload'])) {
         throw new Code404Exception();
     }
     if (!\UserPermissions::hasPerm('wysiwyg_filemanager')) {
         throw new Code401Exception();
     }
     $sLang = Router::getLang();
     \ResponsiveFileManager::$aConfig['default_language'] = $sLang;
 }
Exemple #5
0
 /**
  * Main action to run cron jobs.
  *
  * @access   public
  * @since    2.33.0-dev, 2015-06-07
  * @version  2.39.0-dev
  */
 public function actionDefault()
 {
     if (!class_exists('\\Cron\\CronExpression')) {
         throw new Exception\Fatal('Cannot run Cron jobs without proper Cron library.');
     }
     $sTokenFromURL = Router::getParam('token');
     $sTokenFromConfig = Config::get('base.cron_token');
     $iCronJobsCompleted = 0;
     // check Cron token
     if ($sTokenFromURL !== $sTokenFromConfig) {
         throw new Exception\Code404();
     }
     // get all Cron jobs
     $aAllJobs = CronJobsHelper::getCronJobs();
     // count amount of all CRON jobs
     $iCronJobs = count($aAllJobs);
     // run a single CRON job
     foreach ($aAllJobs as $aJobData) {
         $sModule = $aJobData['module'];
         $sJobKey = base64_encode($aJobData[1] . '.' . $aJobData[2]);
         $aCache = Cache::get($sModule . '.' . $sJobKey, 'cron');
         $iRunDate = isset($aCache['time']) ? $aCache['time'] : NULL;
         $oCron = CronExpression::factory($aJobData[0]);
         if ($iRunDate === NULL || $iRunDate < time()) {
             switch ($aJobData[1]) {
                 case 'route':
                     $sURL = Route::factory($aJobData[2])->url();
                     file_get_contents($sURL);
                     break;
                 case 'file':
                 case 'url':
                     file_get_contents($aJobData[2]);
                     break;
                 case 'function':
                     call_user_func($aJobData[2]);
                     break;
             }
             $iNextRun = $oCron->getNextRunDate()->format('U');
             $aCacheToSave = ['time' => $iNextRun, 'last_execution_time' => time(), 'type' => $aJobData[1], 'param' => $aJobData[2]];
             Cache::set($aCacheToSave, $sModule . '.' . $sJobKey, 'cron', 0);
         }
     }
     // log that cron jobs turning on action was completed
     Log::insert('Cron jobs (in amount of ' . $iCronJobs . ') were checked and ' . $iCronJobsCompleted . ' of them were turned on.');
     // end of functionality
     exit;
 }
Exemple #6
0
 /**
  * ACTION - Particular page.
  *
  * @access   public
  * @return   View
  * @throws   Exception\Code404
  * @throws   Exception\Fatal
  * @since    1.0.1-dev, 2015-04-11
  * @version  1.2.0-dev
  */
 public function actionPage()
 {
     $query = DB::query('SELECT p FROM \\Model\\Page p WHERE p.rewrite = :rewrite');
     $query->param('rewrite', Router::getParam('rewrite'));
     $page = $query->single();
     if (!$page instanceof Model\Page) {
         throw new Exception\Code404('Page does not exist.');
     }
     $this->addBreadCrumb($page->getTitle());
     $this->setTitle($page->getTitle());
     $this->setDescription($page->getDescription());
     $this->setKeywords($page->getKeywords());
     $entityConfig = ViewEntity\Configurator::factory($page);
     $entityConfig->setFields(['content']);
     $viewEntity = ViewEntity::factory($entityConfig);
     return $viewEntity->getView();
 }
Exemple #7
0
<?php

/* @version 1.0.1, 2014-11-27 */
/* @var $oUser \Model\User */
?>

<?php 
if (\Plethora\Router::getParam('id') == \Plethora\Session::get('uid')) {
    ?>
    <p style="text-align: center;">
        <a href="<?php 
    echo \Plethora\Route::factory('user_profile_edit')->url();
    ?>
" title="<?php 
    echo __('Edit profile');
    ?>
">
            [ <?php 
    echo __('Edit profile');
    ?>
 ]
        </a>
    </p>
<?php 
}
?>

<div class="user_profile">
    <table>
        <tbody>
        <tr>
Exemple #8
0
 /**
  * Constructor
  *
  * @access     public
  * @since      1.1.2-dev
  * @version    1.1.3-dev
  */
 public function __construct()
 {
     parent::__construct();
     $this->locales = new \Doctrine\Common\Collections\ArrayCollection();
     // get menu ID
     if (Router::getCurrentRouteName() === 'backend' && in_array(Router::getParam('action'), ['add', 'edit'])) {
         $menuID = (int) Router::getParam('id');
         $this->menu = DB::find('\\Model\\Menu', $menuID);
     }
 }
Exemple #9
0
 /**
  * Action to set new password after e-mail validation.
  *
  * @access   public
  * @return   View
  * @since    1.0.0, 2015-02-17
  * @version  2.1.0-dev
  */
 public function actionNewPassword()
 {
     // fill up breadcrumbs title and other
     $this->addBreadCrumb(__('New password'));
     // get code from $_GET
     $sCode = Router::getParam('code');
     // get recovery code from DB
     $oRecoveryCode = DB::query("SELECT c FROM \\Model\\User\\RecoveryCode c WHERE c.code = :code")->param('code', $sCode)->single();
     /* @var $oResult User\RecoveryCode */
     // check if code exists
     if ($oRecoveryCode instanceof User\RecoveryCode) {
         $this->addToTitle(' - ' . __('New password'));
         // get user
         $oUser = $oRecoveryCode->getUser();
         // generate form for account access recovery
         $oConfig = ModelCore\ModelFormConfig::factory()->noReload()->setFieldsRestriction(['password'])->setMessage(__('Your password has been successfully changed to the new one.'))->setAction(Route::factory('password_recovery')->url());
         // get form
         $oModelForm = $oUser->form('new_password', $oConfig);
         $oForm = $oModelForm->generate();
         // check if form is valid
         if ($oForm->isSubmittedAndValid()) {
             $oRecoveryCode->remove();
             Session::flash(Route::factory('password_recovery')->url(), __('Password has been changed successfully.'));
         }
         $oForm->addToPrefix(View::factory('user/frontend/recovery/new_pass_prefix')->render());
         // return view
         return View::factory('base/form')->bind('oForm', $oForm);
     } else {
         $this->addToTitle(' - ' . __('Error occured'));
         return View::factory('user/frontend/recovery/wrong_code');
     }
 }
Exemple #10
0
 /**
  * This method generates actions in each row of the entity list. By default,
  * there are two actions: "edit" and "delete".
  *
  * @access   protected
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 protected function alterListActions()
 {
     $sControllerParam = Router::getParam('controller');
     $this->addListOption(Route::backendUrl($sControllerParam, 'edit', '{id}'), __('edit'), 'pencil');
     $this->addListOption(Route::backendUrl($sControllerParam, 'delete', '{id}'), __('delete'), 'trash');
 }
Exemple #11
0
 /**
  * ACTION - Users profile on frontend.
  *
  * @access   public
  * @return   View
  * @throws   Exception\Code404
  * @throws   Exception\Fatal
  * @since    1.1.0, 2014-11-22
  * @version  1.3.4, 2015-02-20
  */
 public function actionProfile()
 {
     $iUserID = (int) Router::getParam('id');
     $oUser = Model\User::getUser($iUserID);
     if (empty($oUser)) {
         throw new Exception\Code404(__('This page does not exists.'));
     }
     return View::factory('user/frontend/profile')->bind('oUser', $oUser);
 }
Exemple #12
0
<?php

\Plethora\Router\LocalActions::addLocalAction(__('Edit page'), 'page', 'backend')->setParameters(array('controller' => 'pages', 'action' => 'edit'))->setBuilder(function (\Plethora\Router\LocalActions\Action $oAction) {
    $sPageRewrite = (int) \Plethora\Router::getParam('rewrite');
    $aPage = \Plethora\DB::query('SELECT p.id FROM \\Model\\Page p WHERE p.rewrite = :rewrite')->param('rewrite', $sPageRewrite)->single();
    $oAction->setParameter('id', $aPage['id']);
});
\Plethora\Router\LocalActions::addLocalAction(__('Preview'), 'backend', 'page')->setConditions(array('controller' => 'pages', 'action' => 'edit'))->setBuilder(function (\Plethora\Router\LocalActions\Action $oAction) {
    $iNewsID = (int) \Plethora\Router::getParam('id');
    $oPage = \Plethora\DB::find('Model\\Page', $iNewsID);
    /* @var $oPage \Model\Page */
    $oAction->setParameter('rewrite', $oPage->getRewrite());
});
Exemple #13
0
 /**
  * Generate result (containing entities list) for sort list.
  *
  * @access     protected
  * @return    array
  * @since      1.2.0-dev
  * @version    1.2.0-dev
  */
 protected function alterSortQueryResult()
 {
     $iMenuID = Router::getParam('id');
     $sModelClass = $this->getModel()->getClass();
     return DB::query('SELECT t FROM ' . $sModelClass . ' t WHERE t.menu = :menu_id ORDER BY t.order_number')->param('menu_id', $iMenuID)->execute();
 }
Exemple #14
0
 * @subpackage     views
 * @since          1.0.0-alpha
 * @version        1.0.0-alpha
 */
use Plethora\Route;
use Plethora\Router;
?>

<?php 
/* @var $aList array */
/* @var $oModel \Plethora\ModelCore */
/* @var $sColumn string */
?>

<?php 
$controller = Router::getParam('controller');
?>

<?php 
if (!empty($aList)) {
    ?>
    <ol>
        <?php 
    foreach ($aList as $data) {
        ?>
            <li id="object_<?php 
        echo $data['object']->id;
        ?>
">
                <div class="content">
                    <span class="move glyphicon glyphicon-move"></span>