Пример #1
0
 /**
  * Get HTML link to user profile
  * @param $userId
  * @param $userName
  * @param array $htmlOptions
  * @return string
  */
 public function getProfileLink($userId, $userName, $htmlOptions = [])
 {
     if (isset($this->userProfileLinkCallback) && is_callable($this->userProfileLinkCallback)) {
         return Html::get()->link(call_user_func($this->userProfileLinkCallback, $userId, $userName), $userName, $htmlOptions);
     }
     return Html::get()->link(WebApp::get()->getController()->updateURLWithSection(['user', 'index', ['id' => $userId, 'name' => $userName]]), $userName, $htmlOptions);
 }
Пример #2
0
 /**
  * Get HTML Code for Input
  * @return string
  */
 public function getInput()
 {
     $this->htmlOptions['class'] = (isset($this->htmlOptions['class']) ? $this->htmlOptions['class'] . ' ' : '') . 'input markdown-input';
     $this->htmlOptions['ajax-url'] = $this->previewURL ?: WebApp::get()->request()->getCurrentURL();
     $this->htmlOptions['csrf-key'] = WebApp::get()->request()->getCsrfKey();
     $this->htmlOptions['csrf-value'] = WebApp::get()->request()->getCsrfValue();
     return Form::get()->textarea($this->getName(), $this->getValue(), $this->htmlOptions);
 }
Пример #3
0
 /**
  * Return list of relations for current model
  * @return array
  */
 public static function getRelations()
 {
     $old = parent::getRelations();
     $old['parent'] = [DbRelations::BELONGS_TO, '\\mpf\\modules\\forum\\models\\ForumReplyThird', 'reply_id'];
     $old['replies'] = [DbRelations::HAS_MANY, '\\mpf\\modules\\forum\\models\\ForumReplyFifth', 'reply_id'];
     $old['myVote'] = DbRelation::hasOne(ForumReplyVote::className())->columnsEqual('id', 'reply_id')->hasValue('level', 4)->hasValue('user_id', WebApp::get()->user()->isConnected() ? WebApp::get()->user()->id : 0);
     return $old;
 }
Пример #4
0
 public function beforeSave()
 {
     if ($this->isNewRecord()) {
         $this->added_by = WebApp::get()->user()->id;
         $this->added_time = date('Y-m-d H:i:s');
     }
     return parent::beforeSave();
     // TODO: Change the autogenerated stub
 }
Пример #5
0
 public function actionEdit($id)
 {
     $article = BlogPost::findByPk($id);
     $article->edited_by = WebApp::get()->user()->id;
     $article->edit_time = date('Y-m-d H:i:s');
     $article->edit_number += 1;
     $article->beforeEdit();
     if (isset($_POST['BlogPost']) && $article->setAttributes(['anonimous' => 0]) && $article->setAttributes($_POST['BlogPost'])->save()) {
         $article->afterAdminEdit();
         $this->goToPage('home', 'read', ['id' => $article->id, 'title' => $article->url]);
     }
     $this->assign('model', $article);
     Messages::get()->info("Add " . BlogConfig::get()->introductionSeparator . " to set the limit for text displayed on the articles list!");
 }
Пример #6
0
 public function actionControlPanel()
 {
     if (WebApp::get()->user()->isGuest()) {
         $this->goToPage('user', 'login', [], '');
     }
     $user = ForumUser2Section::findByAttributes(['user_id' => WebApp::get()->user()->id, 'section_id' => $this->sectionId]);
     $user->icon = $user->user->icon;
     if (isset($_POST['ForumUser2Section'])) {
         $user->signature = $_POST['ForumUser2Section']['signature'];
         $user->save();
         $user->changeIcon();
         $user->icon = $user->user->icon;
         WebApp::get()->user()->setState('icon', $user->user->icon);
     }
     $this->assign('model', $user);
 }
Пример #7
0
 /**
  * Before running any action it will check if user has access to edit current section. To edit subcategories for
  * a single category other admins will have access to a special smaller interface(or maybe this one in the future).
  * @param $actionName
  * @return bool
  */
 public function beforeAction($actionName)
 {
     parent::beforeAction($actionName);
     if (WebApp::get()->user()->isGuest()) {
         $this->goToPage('user', 'login', [], '');
     }
     if (!UserAccess::get()->isSectionAdmin($this->sectionId)) {
         if (in_array($actionName, ['users', 'titles']) && UserAccess::get()->isSectionModerator($this->sectionId)) {
             return true;
         }
         Messages::get()->error("You don't have the required rights to access this section!");
         $this->goToPage('special', 'accessDenied');
         die;
     }
     return true;
 }
Пример #8
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (!$this->filePath) {
         // no file selected
         return;
     }
     if ($this->_writeFailure) {
         // there are problems with writing to file; no need to keep retrying
         return;
     }
     if (!$this->_path) {
         if (!is_a(App::get(), '\\mpf\\WebApp')) {
             $this->_path = $this->filePath;
         } else {
             $this->_path = str_replace(['{MODULE}', '{CONTROLLER}'], [WebApp::get()->request()->getModule(), WebApp::get()->request()->getController()], $this->filePath);
         }
         $this->_path = str_replace("{APP_ROOT}", APP_ROOT, $this->_path);
     }
     if (!in_array($level, $this->visibleLevels)) {
         return;
     }
     if (Levels::DEBUG == $level && isset($context['fromClass']) && in_array($context['fromClass'], $this->ignoredClasses)) {
         return;
     }
     $details = date("Y-m-d H:i ") . (isset($context['fromClass']) ? $context['fromClass'] : '') . " {$message}\n";
     if (in_array($level, $this->detaliedLevels)) {
         foreach ($context as $k => $v) {
             if ('fromClass' == $k) {
                 continue;
             }
             if (is_string($v) || is_numeric($v)) {
                 $details .= " {$k} => " . $v . "\n";
             } elseif (is_bool($v)) {
                 $details .= " {$k} => " . ($v ? 'true' : 'false') . "\n";
             } elseif (is_a($v, '\\Exception')) {
                 /* @var $v \Exception */
                 $details .= " Location: " . $v->getFile() . ' [' . $v->getLine() . ']:';
                 $details .= "\n" . $v->getTraceAsString();
             } else {
                 $details .= " {$k} => " . print_r($v, true);
             }
         }
     }
     if (false === @file_put_contents($this->_path, $details . "\n", FILE_APPEND)) {
         $this->_writeFailure = true;
     }
 }
Пример #9
0
 public function actionDelete()
 {
     $models = User::findAllByPk($_POST['User']);
     $number = 0;
     $names = [];
     foreach ($models as $model) {
         $names[] = $model->name;
         $number += (int) $model->delete();
     }
     User::findByPk(WebApp::get()->user()->id)->logAction(UserHistory::ACTION_ADMINDELETE, "Users: \n", implode("\n   ", $names));
     if (1 !== $number) {
         Messages::get()->success("User deleted!");
     } else {
         Messages::get()->success("{$number} users deleted!");
     }
     $this->getRequest()->goBack();
 }
Пример #10
0
 public function actionAction()
 {
     if (!isset($_POST['action'])) {
         $this->goToPage('special', 'notFound');
     }
     switch ($_POST['action']) {
         case "show_subcategory":
             WebApp::get()->sql()->table("forum_userhiddensubcategories")->where("user_id = :user AND subcategory_id = :subcategory")->setParams([':user' => WebApp::get()->user()->id, ':subcategory' => $_POST['id']])->delete();
             $this->goBack();
             break;
         case "hide_subcategory":
             WebApp::get()->sql()->table("forum_userhiddensubcategories")->insert(['user_id' => WebApp::get()->user()->id, 'subcategory_id' => $_POST['id']], "ignore");
             $this->goBack();
             break;
         default:
             $this->goToPage('special', 'notFound');
     }
 }
Пример #11
0
 public function beforeSave()
 {
     if (WebApp::get()->user()->isConnected()) {
         $this->user_id = WebApp::get()->user()->id;
         $this->username = WebApp::get()->user()->name;
         $this->email = WebApp::get()->user()->email;
     } elseif (!trim($this->email)) {
         $this->setError('email', 'Email is required  for guests!');
         return false;
     } elseif (!trim($this->username)) {
         $this->setError('username', 'Name is required for quests!');
         return false;
     }
     $this->published_time = date('Y-m-d H:i:s');
     $this->status = BlogComment::STATUS_OK;
     return parent::beforeSave();
     // TODO: Change the autogenerated stub
 }
Пример #12
0
 /**
  * Get a HTML list of links used for menus
  * @param $items
  * @param array $htmlOptions
  * @return string
  */
 public static function menuList($items, $htmlOptions = array())
 {
     $lis = array();
     foreach ($items as $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_array($item['url'])) {
             if (WebApp::get()->accessMap && !WebApp::get()->accessMap->canAccess($item['url'][0], isset($item['url'][1]) ? $item['url'][1] : null, isset($item['url'][2]) ? $item['url'][2] : null)) {
                 continue;
             }
         }
         $url = is_array($item['url']) ? WebApp::get()->request()->createURL($item['url'][0], isset($item['url'][1]) ? $item['url'][1] : null, isset($item['url'][2]) ? $item['url'][2] : array(), isset($item['url'][3]) ? $item['url'][3] : null) : $item['url'];
         $icon = isset($item['icon']) ? Html::get()->image($item['icon'], self::get()->translate(isset($item['title']) ? $item['title'] : (isset($item['label']) ? $item['label'] : '')), isset($item['iconHtmlOptions']) ? $item['iconHtmlOptions'] : array()) : '';
         $itemContent = Html::get()->link($url, $icon . self::get()->translate(isset($item['label']) ? $item['label'] : ''), isset($item['linkHtmlOptions']) ? $item['linkHtmlOptions'] : array());
         $lis[] = Html::get()->tag('li', $itemContent, isset($item['htmlOptions']) ? $item['htmlOptions'] : array());
     }
     return count($lis) ? Html::get()->tag('ul', implode("\n", $lis), $htmlOptions) : '';
 }
Пример #13
0
        <?php 
echo $article->getContent(true);
?>
    </div>
</div>

<?php 
if (\mpf\modules\blog\components\BlogConfig::get()->allowComments) {
    ?>
    <div class="blog-article-comments">
        <?php 
    if ($article->allow_comments) {
        ?>
            <div class="comment-form">
                <?php 
        if (\mpf\WebApp::get()->user()->isGuest()) {
            ?>
                    <?php 
            echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'fields' => ['username', 'email', ['name' => 'text', 'type' => 'textarea']]])->display();
            ?>
                <?php 
        } else {
            ?>
                    <?php 
            echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'fields' => [['name' => 'text', 'type' => 'textarea']]])->display();
            ?>
                <?php 
        }
        ?>
            </div>
Пример #14
0
 /**
  * Update(/insert) config value for selected user.
  * @param string $key
  * @param string $value
  * @param null|int $user
  * @return bool|int
  */
 public static function set($key, $value, $user = null)
 {
     $user = $user ?: WebApp::get()->user()->id;
     $s = self::getDb()->table(self::getTableName())->insert(['name' => $key, 'value' => $value, 'user_id' => $user], ['value' => $value]);
     self::updateCache($user, true);
     return $s;
 }
Пример #15
0
<?php

$actions = array('crontab' => 'View All', 'addcron' => 'Add Job');
$menu = array();
foreach ($actions as $action => $label) {
    $menu[] = array('url' => array('admin', $action), 'label' => $label, 'htmlOptions' => $action == \mpf\WebApp::get()->request()->getAction() ? array('class' => 'selected') : array());
}
echo \app\components\htmltools\Page::title('Crontab - Edit Job', $menu);
echo \mpf\widgets\form\Form::get(array('name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'fields' => array('user', 'interval', 'command', 'log', array('name' => 'enabled', 'type' => 'select', 'options' => array('No', 'Yes'))), 'formHtmlOptions' => array('autocomplete' => 'off')))->display();
Пример #16
0
 /**
  * Check if current users can edit articles that  are not his/her own
  * @return bool
  */
 public static function canEditOtherArticles()
 {
     if (WebApp::get()->user()->isGuest()) {
         return false;
     }
     if (is_callable(self::get()->canEditOtherArticlesCallback)) {
         return call_user_func(self::get()->canEditOtherArticlesCallback);
     }
     return false;
 }
Пример #17
0
 public static function notifyUser($type, $url, $vars, $user = null)
 {
     $originalType = $type;
     $type = Config::value('FORUM_NOTIFICATIONS_TYPES_PREFIX') . $type;
     if (!Type::findByName($type, true)) {
         $typeModel = new Type();
         $typeModel->name = $type;
         $typeModel->description = "Automatically generated by the forum module! Can be edited to change the messages sent.";
         $typeModel->email = self::getDefaultEmailForType($originalType);
         $typeModel->sms = $typeModel->web = $typeModel->mobile = self::getDefaultMessageForType($originalType);
         $typeModel->save();
     }
     return Notifications::add($type, $url, $vars, $user ?: WebApp::get()->user()->id);
 }
Пример #18
0
 public function init($config)
 {
     $this->options = ['script_url' => $this->uploader->dataUrl, 'upload_dir' => $this->uploader->uploadDir ?: dirname($_SERVER['SCRIPT_FILENAME']) . '/uploads/', 'upload_url' => $this->uploader->uploadURL ?: WebApp::get()->request()->getWebRoot() . 'uploads/', 'mkdir_mode' => 0775, 'param_name' => $this->uploader->name, 'delete_type' => 'DELETE', 'access_control_allow_origin' => '*', 'access_control_allow_credentials' => false, 'access_control_allow_methods' => ['OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE'], 'access_control_allow_headers' => ['Content-Type', 'Content-Range', 'Content-Disposition'], 'download_via_php' => false, 'readfile_chunk_size' => 10 * 1024 * 1024, 'inline_file_types' => '/\\.(gif|jpe?g|png)$/i', 'accept_file_types' => '/.+$/i', 'max_file_size' => null, 'min_file_size' => 1, 'max_number_of_files' => null, 'image_file_types' => '/\\.(gif|jpe?g|png)$/i', 'correct_image_extensions' => false, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'image_library' => 1, 'convert_bin' => 'convert', 'identify_bin' => 'identify', 'image_versions' => ['' => ['auto_orient' => true], 'thumbnail' => ['max_width' => 200, 'max_height' => 200]], 'print_response' => true] + $this->options;
     parent::init($config);
 }
Пример #19
0
if (\mpf\WebApp::get()->user()->isGuest()) {
    ?>
    <?php 
    return;
}
?>
<div class="forum-user-panel">
    <div class="forum-user-panel-icon">
        <?php 
echo \mpf\web\helpers\Html::get()->link(['user', 'controlPanel'], \mpf\web\helpers\Html::get()->image(\mpf\modules\forum\components\ModelHelper::getUserIconURL(\mpf\WebApp::get()->user()->icon ?: 'default.png')));
?>
    </div>
    <div class="forum-user-panel-about">
        <?php 
echo \mpf\web\helpers\Html::get()->link(['user', 'index', ['id' => \mpf\WebApp::get()->user()->id, 'name' => \mpf\WebApp::get()->user()->name]], \mpf\WebApp::get()->user()->name, ['class' => 'form-user-panel-about-name']);
?>
        <span
            class="form-user-panel-about-title"><?php 
echo \mpf\modules\forum\components\UserAccess::get()->getUserTitle($this->sectionId, true);
?>
</span>
    </div>
    <div class="forum-user-panel-links">
        <?php 
echo \mpf\web\helpers\Html::get()->link(['home'], \mpf\modules\forum\components\Translator::get()->translate('Categories'));
?>
        <?php 
echo \mpf\web\helpers\Html::get()->link(['user', 'controlPanel'], \mpf\modules\forum\components\Translator::get()->translate('Control Panel'));
?>
        <?php 
Пример #20
0
    public function sendPasswordToNewAccount(User $user, $password)
    {
        $adminName = WebApp::get()->user()->name;
        $message = <<<MESSAGE
Hello {user->name},

An account has been created for you by {adminName} on <a href="{this->getLinkRoot()}">{this->website}</a>.

To login use the following data:
Email: {user->email}
Password: {password}

Regards,
{this->website}
MESSAGE;
        $message = nl2br(eval("return <<<MESSAGE\n" . str_replace(array('{user', '{this', '{adminName', '{password'), array('{$user', '{$this', '{$adminName', '{$password'), $this->translate($message)) . "\nMESSAGE;\n"));
        return $this->sendEmail('Password for new account on ' . $this->website, $message, $user->email, $user->name);
    }
Пример #21
0
<?php

$actions = array('index' => 'View All', 'create' => 'Add Group');
$menu = array();
foreach ($actions as $action => $label) {
    $menu[] = array('url' => array('usergroups', $action), 'label' => $label, 'htmlOptions' => $action == $this->getActiveAction() ? array('class' => 'selected') : array());
}
echo \app\components\htmltools\Page::title('Users Groups - ' . $actions[$this->getActiveAction()], $menu);
\mpf\widgets\datatable\Table::get(array('dataProvider' => $model->getDataProvider(), 'multiSelect' => true, 'multiSelectActions' => array('delete' => array('label' => 'Delete', 'icon' => \mpf\web\AssetsPublisher::get()->mpfAssetFile('images/oxygen/16x16/actions/edit-delete.png'), 'shortcut' => 'Shift+Delete', 'url' => \mpf\WebApp::get()->request()->createURL("usergroups", "delete"))), 'columns' => array('id' => array('headerHtmlOptions' => array('style' => 'width:60px;'), 'htmlOptions' => array('style' => 'text-align:center;')), 'name', 'label', array('class' => 'Actions', 'headerHtmlOptions' => array('style' => 'width:40px;'), 'buttons' => array('edit' => array('class' => 'Edit'), 'delete' => array('class' => 'Delete')), 'topButtons' => array('add' => array('class' => 'Add'))))))->display();
Пример #22
0
<?php

$actions = array('index' => 'View All', 'create' => 'New User');
$menu = array();
foreach ($actions as $action => $label) {
    $menu[] = array('url' => array('users', $action), 'label' => $label, 'htmlOptions' => $action == $this->getActiveAction() ? array('class' => 'selected') : array());
}
echo \app\components\htmltools\Page::title('Users - ' . $actions[$this->getActiveAction()], $menu);
\mpf\widgets\datatable\Table::get(array('dataProvider' => $model->getDataProvider(), 'multiSelect' => true, 'multiSelectActions' => array('delete' => ['label' => 'Delete', 'icon' => \mpf\web\AssetsPublisher::get()->mpfAssetFile('images/oxygen/16x16/actions/edit-delete.png'), 'shortcut' => 'Shift+Delete', 'url' => \mpf\WebApp::get()->request()->createURL("users", "delete"), 'confirmation' => 'Are you sure?'], 'enable' => ['label' => 'Enable', 'icon' => \mpf\web\AssetsPublisher::get()->mpfAssetFile('images/oxygen/16x16/actions/dialog-ok-apply.png'), 'url' => \mpf\WebApp::get()->request()->createURL("users", "index")], 'disable' => ['label' => 'Disable', 'icon' => \mpf\web\AssetsPublisher::get()->mpfAssetFile('images/oxygen/16x16/actions/dialog-cancel.png'), 'url' => \mpf\WebApp::get()->request()->createURL("users", "index")], 'join' => ['label' => 'Join Accounts', 'icon' => \mpf\web\AssetsPublisher::get()->mpfAssetFile('images/oxygen/16x16/actions/im-msn.png'), 'url' => \mpf\WebApp::get()->request()->createURL("users", "merge"), 'confirmation' => 'Are you sure? After this user can log in on any of those accounts and see data from all of them.[where this is supported]']), 'columns' => array('name', 'email', 'register_date' => array('class' => 'Date'), 'last_login' => array('class' => 'Date'), 'last_login_source' => array('filter' => array('post' => 'POST', 'cookie' => 'Cookie', 'facebook' => 'Facebook', 'google' => 'Google')), 'status' => array('class' => 'Select', 'filter' => \app\models\User::getStatuses()), array('class' => 'Actions', 'buttons' => array('delete' => array('class' => 'Delete'), 'edit' => array('class' => 'Edit'), 'view' => array('class' => 'View')), 'headerHtmlOptions' => array('style' => 'width:60px;'), 'topButtons' => array('add' => array('class' => 'Add'))))))->display();
Пример #23
0
echo \mpf\WebApp::get()->title;
?>
</title>
    <?php 
echo \mpf\web\helpers\Html::get()->cssFile(\mpf\WebApp::get()->request()->getWebRoot() . 'main/style.css');
?>
    <?php 
echo \mpf\web\helpers\Html::get()->mpfScriptFile('jquery.js');
?>
    <?php 
echo \mpf\web\helpers\Html::get()->scriptFile(\mpf\WebApp::get()->request()->getWebRoot() . 'main/main.js');
?>
</head>
<body>
<div id="wrapper">
    <div id="site">
        <div id="header">
            <h1><?php 
echo \mpf\web\helpers\Html::get()->link(\mpf\WebApp::get()->request()->getLinkRoot(), \mpf\WebApp::get()->title);
?>
</h1>
            <?php 
\mpf\widgets\menu\Menu::get(['items' => [['url' => [], 'label' => 'Home'], ['url' => ['user', 'login'], 'label' => 'Login', 'visible' => \mpf\WebApp::get()->user()->isGuest()], ['url' => ['user', 'register'], 'label' => 'Register', 'visible' => \mpf\WebApp::get()->user()->isGuest()], ['url' => ['user', 'forgotpassword'], 'label' => 'Forgot Password', 'visible' => \mpf\WebApp::get()->user()->isGuest()], ['class' => 'Label', 'label' => \mpf\WebApp::get()->user()->isGuest() ? 'Welcome Guest!' : 'Welcome ' . \mpf\WebApp::get()->user()->name, 'htmlOptions' => ['style' => 'float:right;'], 'items' => [['url' => ['user', 'profile'], 'label' => 'My Profile'], ['url' => ['user', 'edit'], 'label' => 'Edit My Profile'], ['url' => ['user', 'email'], 'label' => 'Change Email'], ['url' => ['user', 'password'], 'label' => 'Change Password'], ['url' => ['home', 'index', 'admin'], 'label' => 'Administration'], ['url' => ['user', 'logout'], 'label' => 'Logout']]], ['label' => 'Google Login', 'url' => $url = \mpf\WebApp::get()->user()->getGoogleClient() ? \mpf\WebApp::get()->user()->getGoogleClient()->createAuthUrl() : null, 'htmlOptions' => ['style' => 'float:right;'], 'linkHtmlOptions' => ['class' => 'ext-login-button google-login-button'], 'visible' => \mpf\WebApp::get()->user()->isGuest() && trim($url)], ['label' => 'Facebook Login', 'url' => $url = \mpf\WebApp::get()->user()->getFacebookLoginURL(), 'visible' => \mpf\WebApp::get()->user()->isGuest() && trim($url), 'htmlOptions' => ['style' => 'float:right;'], 'linkHtmlOptions' => ['class' => 'ext-login-button facebook-login-button']]]])->display();
?>
        </div>
        <div id="content">
            <?php 
echo \app\components\htmltools\Messages::get()->display();
?>

Пример #24
0
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MPF Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MPF Framework.  If not, see <http://www.gnu.org/licenses/>.
 */
define('LIBS_FOLDER', dirname(__DIR__) . DIRECTORY_SEPARATOR);
define('APP_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
/**
 * Set ErrorException for every error;
 */
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    $severity = 1 * E_ERROR | 1 * E_WARNING | 1 * E_PARSE | 1 * E_NOTICE | 0 * E_CORE_ERROR | 0 * E_CORE_WARNING | 0 * E_COMPILE_ERROR | 0 * E_COMPILE_WARNING | 1 * E_USER_ERROR | 1 * E_USER_WARNING | 1 * E_USER_NOTICE | 0 * E_STRICT | 0 * E_RECOVERABLE_ERROR | 0 * E_DEPRECATED | 0 * E_USER_DEPRECATED;
    $ex = new ErrorException($errstr, 0, $errno, $errfile, $errline);
    if (($ex->getSeverity() & $severity) != 0) {
        throw $ex;
    }
});
require_once LIBS_FOLDER . 'mpf' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
mpf\base\AutoLoader::get()->register();
use mpf\WebApp as App;
use mpf\base\Config;
new Config(__DIR__ . DIRECTORY_SEPARATOR . 'config/web.inc.php');
\mpf\base\AutoLoader::get()->applyConfig(Config::get()->forClass('\\mpf\\base\\AutoLoader'));
App::run(array('requestClass' => '\\mpf\\web\\request\\SOAP'));
Пример #25
0
 public function beforeSave()
 {
     if ($this->isNewRecord()) {
         $this->user_id = WebApp::get()->user()->id;
     }
     return parent::beforeSave();
 }
Пример #26
0
<?php

use app\components\htmltools\Page;
$actions = array('profile' => 'View Profile', 'edit' => 'Edit Profile', 'email' => 'Change Email', 'password' => 'Change Password', 'login' => 'Login', 'forgotpassword' => 'Forgot Password');
$menu = array();
foreach ($actions as $action => $label) {
    $menu[] = array('url' => array('user', $action), 'label' => $label, 'visible' => 'registerauto' == $action ? false : (in_array($action, array('login', 'register', 'forgotpassword')) ? \mpf\WebApp::get()->user()->isGuest() : \mpf\WebApp::get()->user()->isConnected()), 'htmlOptions' => $action == \mpf\WebApp::get()->request()->getAction() ? array('class' => 'selected') : array());
}
?>

<?php 
echo Page::title('User - ' . $actions[\mpf\WebApp::get()->request()->getAction()], $menu);
Пример #27
0
 /**
  * Check if current item is visible or not.
  * @return boolean
  */
 public function isVisible()
 {
     if (!is_array($this->url) || !$this->visible) {
         // if it's not array, or not visible then just return visible value, no need to check anything
         return $this->visible;
     }
     $controller = isset($this->url[0]) ? $this->url[0] : 'home';
     $action = isset($this->url[1]) ? $this->url[1] : null;
     if (false !== strpos($controller, '/')) {
         list($module, $controller) = explode('/', $controller, 2);
         if ('..' == $module) {
             $module = '/';
         }
     } else {
         $module = isset($this->url[2]) && is_string($this->url[2]) ? $this->url[2] : (isset($this->url[3]) ? $this->url[3] : null);
     }
     if (\mpf\WebApp::get()->accessMap && !\mpf\WebApp::get()->accessMap->canAccess($controller, $action, $module)) {
         return false;
     }
     return true;
 }
Пример #28
0
 /**
  * Publish a single file
  * @param string $path
  * @return string Published URL
  */
 public function publishFile($path)
 {
     $newName = dirname(SCRIPT_FILENAME) . DIRECTORY_SEPARATOR . $this->publishFolder . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . md5($path) . '_' . basename($path);
     $url = \mpf\WebApp::get()->request()->getWebRoot() . $this->publishFolder . "/files/" . md5($path) . '_' . basename($path);
     if ($this->_isPublished($newName)) {
         return $newName;
     }
     $this->_file($path, $newName);
     $this->publishCache[$newName] = true;
     return $url;
 }
Пример #29
0
 /**
  * Display form.
  */
 public function display()
 {
     $this->publishAssets();
     if (!isset($this->htmlOptions['class'])) {
         $this->htmlOptions['class'] = 'mform mform-' . $this->theme;
     } else {
         $this->htmlOptions['class'] .= 'mform mform-' . $this->theme;
     }
     if ($this->action) {
         $this->formHtmlOptions['action'] = is_string($this->action) ? $this->action : WebApp::get()->request()->createURL($this->action[0], isset($this->action[1]) ? $this->action[1] : null, isset($this->action[2]) ? $this->action[2] : [], isset($this->action[3]) ? $this->action[3] : null);
     }
     $this->formHtmlOptions['method'] = $this->method;
     return HtmlHelper::get()->tag('div', FormHelper::get()->openForm($this->formHtmlOptions) . $this->getContent() . FormHelper::get()->closeForm(), $this->htmlOptions);
 }
Пример #30
0
 /**
  * @return string
  */
 public function getActiveLanguage()
 {
     if (1 === count($this->languages)) {
         return $this->languages[0];
     }
     $l = WebApp::get()->request()->getLanguage();
     if (!in_array($l, $this->languages)) {
         return $this->languages[0];
     }
     return $l;
 }