コード例 #1
0
ファイル: SiteController.php プロジェクト: megabr/web3cms
 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $contact = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $contact->attributes = $_POST['ContactForm'];
         if ($contact->validate()) {
             $headers = "From: {$contact->email}\r\nReply-To: {$contact->email}";
             @mail(MParams::getAdminEmailAddress(), $contact->subject, $contact->content, $headers);
             MUserFlash::setTopInfo(Yii::t('hint', 'Thank you for contacting us. We will respond to you as soon as possible.'));
             $this->refresh();
         }
     }
     $this->render($this->action->id, array('contact' => $contact));
 }
コード例 #2
0
ファイル: LocationController.php プロジェクト: megabr/web3cms
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadModel();
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     // whether data is passed
     if (isset($_POST['Location'])) {
         // collect user input data
         $model->attributes = $_POST['Location'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" location record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #3
0
ファイル: UserController.php プロジェクト: megabr/web3cms
 /**
  * Logout the current user and redirect to homepage.
  */
 public function actionLogout()
 {
     $isLoggedIn = !Yii::app()->user->isGuest;
     $screenName = $isLoggedIn ? Yii::app()->user->screenName : '';
     // log user out and destroy all session data
     // if you want to keep the session alive, then use Yii::app()->user->logout(false) instead
     Yii::app()->user->logout();
     // if user was logged in, we should notify about logout
     if ($isLoggedIn) {
         if (!Yii::app()->getSession()->getIsStarted()) {
             // if session is destroyed, we need to re-open it. this is necessary for user flash
             Yii::app()->getSession()->open();
         }
         // set the goodbye message
         MUserFlash::setTopInfo(Yii::t('hint', '{screenName}, you have been successfully logged out.', array('{screenName}' => MHtml::wrapInTag($screenName, 'strong'))));
     }
     // go to home page
     $this->redirect(Yii::app()->homeUrl);
 }
コード例 #4
0
ファイル: register.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Register a member account'));
MUserFlash::setTopError(_CHtml::errorSummary($model));
MUserFlash::setSidebarInfo(Yii::t('hint', 'Create a new member account. It\'s free and easy!'));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('text' => Yii::t('link', 'Members'), 'url' => array($this->id . '/' . $this->defaultAction), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/' . $this->defaultAction)), array('url' => array($this->action->id), 'active' => true))));
?>
<div class="w3-main-form-box ui-widget-content ui-corner-all">

<?php 
echo _CHtml::beginForm('', 'post', array('class' => 'w3-main-form')) . "\n";
?>

<?php 
if ($model->hasVirtualAttribute('username')) {
    ?>
<div class="w3-form-row w3-first">
  <div class="w3-form-row-label"><?php 
    echo _CHtml::activeLabelEx($model, 'username');
    ?>
</div>
  <div class="w3-form-row-input">
    <?php 
    echo _CHtml::activeTextField($model, 'username', array('class' => 'w3-input-text ui-widget-content ui-corner-all', 'maxlength' => 32)) . "\n";
    ?>
  </div>
  <div class="clear">&nbsp;</div>
</div>
<div class="w3-form-row">
  <div class="w3-form-row-label"><?php 
    echo _CHtml::activeLabelEx($model, 'screenName');
コード例 #5
0
ファイル: ProjectController.php プロジェクト: megabr/web3cms
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadModel(array('with' => array('allCompany2Project', 'allManager2Project')));
     if ($model === null) {
         // model not found
         MUserFlash::setTopError(Yii::t('modelNotFound', $this->id));
         $this->redirect($this->getGotoUrl());
     }
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     // whether data is passed
     if (isset($_POST['Project'])) {
         // collect user input data
         $model->attributes = $_POST['Project'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['Company2Project'])) {
                 // assigned companies
                 $hasCompany = isset($model->allCompany2Project[0]->id);
                 if (!$hasCompany) {
                     $model->allCompany2Project = array(0 => new Company2Project('create'));
                     $model->allCompany2Project[0]->projectId = $model->id;
                 }
                 foreach ($model->allCompany2Project as $company2Project) {
                     // collect user input data
                     $company2Project->attributes = $_POST['Company2Project'];
                     // at the crossroads: which action is expected to be performed
                     if ($hasCompany && empty($company2Project->companyId)) {
                         // un-assigned associated record
                         $company2Project->delete();
                     } else {
                         // validate and create/update record
                         $company2Project->save();
                     }
                 }
             }
             if (isset($_POST['User2Project'])) {
                 // assigned managers
                 $hasManager = isset($model->allManager2Project[0]->id);
                 if (!$hasManager) {
                     $model->allManager2Project = array(0 => new User2Project('create'));
                     $model->allManager2Project[0]->projectId = $model->id;
                 }
                 foreach ($model->allManager2Project as $manager2Project) {
                     // collect user input data
                     $manager2Project->attributes = $_POST['User2Project'];
                     // at the crossroads: which action is expected to be performed
                     if ($hasManager && empty($manager2Project->userId)) {
                         // un-assigned associated record
                         $manager2Project->delete();
                     } else {
                         // validate and create/update record
                         $manager2Project->save();
                     }
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" project record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     if (!isset($model->allCompany2Project[0])) {
         // new associated company
         $model->allCompany2Project = array(0 => new Company2Project('create'));
         $model->allCompany2Project[0]->projectId = $model->id;
     }
     if (!isset($model->allManager2Project[0])) {
         // new associated manager
         $model->allManager2Project = array(0 => new User2Project('create'));
         $model->allManager2Project[0]->projectId = $model->id;
         $model->allManager2Project[0]->role = User2Project::MANAGER;
     }
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #6
0
ファイル: _CController.php プロジェクト: megabr/web3cms
 /**
  * Performs access check before action is executed.
  * If access is denied - redirect to an appropriate page or display an empty screen.
  * See {@link getCheckAccessOnActions} for the list of actions to check access for.
  * @param CAction the action to be executed.
  */
 public function checkAccessBeforeAction()
 {
     $actionId = $this->action->id;
     $checkAccessOnActions = $this->getCheckAccessOnActions();
     if (array_key_exists($actionId, $checkAccessOnActions)) {
         $a = $checkAccessOnActions[$actionId];
         // first check whether it should be an ajax or a post request
         if (!isset($a['request']) || $a['request'] === 'ajax' && Yii::app()->request->isAjaxRequest || $a['request'] === 'post' && Yii::app()->request->isPostRequest) {
             // define route and other variables
             if (!isset($a['route']) && (isset($a['moduleId']) || isset($a['controllerId']) || isset($a['actionId']))) {
                 $routeA = array();
                 if (isset($a['moduleId']) || $this->module) {
                     $routeA['moduleId'] = isset($a['moduleId']) ? $a['moduleId'] : $this->module->id;
                 }
                 $routeA['controllerId'] = isset($a['controllerId']) ? $a['controllerId'] : $this->id;
                 $routeA['actionId'] = isset($a['actionId']) ? $a['actionId'] : $this->action->id;
                 $route = implode('/', $routeA);
             } else {
                 $route = isset($a['route']) ? $a['route'] : $this->route;
             }
             if (!isset($routeA)) {
                 // attempt to generate access route
                 $routeT = explode('/', $route);
                 if (count($routeT) == 2) {
                     $routeA = array('controllerId' => $routeT[0], 'actionId' => $routeT[1]);
                 } else {
                     if (count($routeT) == 3) {
                         $routeA = array('moduleId' => $routeT[0], 'controllerId' => $routeT[1], 'actionId' => $routeT[2]);
                     }
                 }
                 unset($routeT);
             }
             $params = isset($a['params']) && is_array($a['params']) ? $a['params'] : array();
             foreach ($params as $key => $value) {
                 if (isset($value['call_user_func'])) {
                     $params[$key] = call_user_func(array($this, $value['call_user_func']));
                 }
             }
             // use power of rbac. see {@link _CUserIdentity::authorize} for assignment
             if (!Yii::app()->user->checkAccess($route, $params)) {
                 // access denied
                 // define error message variable
                 if (!isset($a['messageRoute']) && (isset($a['messageModuleId']) || isset($a['messageControllerId']) || isset($a['messageActionId']))) {
                     $routeM = array();
                     if (isset($a['messageModuleId']) || $this->module) {
                         $routeM['messageModuleId'] = isset($a['messageModuleId']) ? $a['messageModuleId'] : (isset($routeA['moduleId']) ? $routeA['moduleId'] : $this->module->id);
                     }
                     $routeM['messageControllerId'] = isset($a['messageControllerId']) ? $a['messageControllerId'] : (isset($routeA['controllerId']) ? $routeA['controllerId'] : $this->id);
                     if (isset($a['messageActionId'])) {
                         if (is_array($a['messageActionId'])) {
                             foreach ($a['messageActionId'] as $id => $bizRule) {
                                 if (empty($bizRule) || @eval($bizRule) != 0) {
                                     $routeM['messageActionId'] = $id;
                                 }
                             }
                         } else {
                             $routeM['messageActionId'] = $a['messageActionId'];
                         }
                     }
                     if (!isset($routeM['messageActionId'])) {
                         $routeM['messageActionId'] = isset($routeA['actionId']) ? $routeA['actionId'] : $this->action->id;
                     }
                     $messageRoute = implode('/', $routeM);
                 } else {
                     $messageRoute = isset($a['messageRoute']) ? $a['messageRoute'] : $route;
                 }
                 $message = Yii::t('accessDenied', $messageRoute);
                 // do what expected: exit or print json or redirect
                 if ($a === 'exit' || isset($a['do']) && $a['do'] === 'exit') {
                     // this results in an empty screen. good for simple ajax requests
                     return false;
                 } else {
                     if ($a === 'json' || isset($a['do']) && $a['do'] === 'json') {
                         // print out json document with error message.
                         // ideal for ajax requests that expect a status and a message to be returned
                         $this->printJsonExit(array('status' => 'error', 'message' => $message));
                         return false;
                     } else {
                         // set error message. should be displayed when redirect will be completed
                         MUserFlash::setTopError($message);
                         // FIXME
                         MUserFlash::setSidebarInfo(Yii::t('hint', 'Hint: Check <tt>components/_CUserIdentity:authorize()</tt> to change allowed actions.'));
                         // redirect now to user/login, user/show or to a more appropriate page
                         $this->redirect($this->getGotoUrl());
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #7
0
ファイル: UserController.php プロジェクト: megabr/web3cms
 /**
  * Update user interface.
  * Accessible only to authenticated users and admin.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdateInterface()
 {
     if (!Yii::app()->user->checkAccess($this->route, array('model' => $this->loadModel()))) {
         // access denied
         MUserFlash::setTopError(Yii::t('accessDenied', $this->route));
         $this->redirect($this->getGotoUrl());
     }
     $pkIsPassed = isset($_GET['id']);
     if (($model = $this->loadModel()) === null) {
         // model not found
         MUserFlash::setTopError(Yii::t('modelNotFound', $this->id));
         $this->redirect($this->getGotoUrl());
     }
     // explicitly set model scenario to be current action
     $model->setScenario($this->action->id);
     if (is_object($model->details)) {
         $model->details->setScenario($this->action->id);
     }
     // whether data is passed
     if (isset($_POST['User'])) {
         // collect user input data
         $model->attributes = $_POST['User'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // take care of updateTime (this is not critical)
             $model->details->saveAttributes(array('updateTime' => time()));
             // update variables first defined in {@link _CUserIdentity} class
             if ($model->isMe) {
                 // update user states in the session for {@link _CController::init}
                 Yii::app()->user->setState('interface', $model->interface);
                 // set user preferred interface
                 if (!empty($model->interface)) {
                     W3::setInterface($model->interface);
                 }
                 // we do not need to update user cookie any more because
                 // we overrode auto-login with {@link _CWebUser::restoreFromCookie}
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', $model->isMe ? '{screenName}, new user interface has been applied.' : 'The user interface for member account "{screenName}" has been updated.', array('{screenName}' => MHtml::wrapInTag($model->screenName, 'strong'))));
             // go to 'show' page
             $this->redirect($model->isMe ? array('show') : array('show', 'id' => $model->id));
         } else {
             if ($validated && !$saved) {
                 // set error message
                 MUserFlash::setTopError(Yii::t('hint', $model->isMe ? 'Error! {screenName}, new user interface could not be applied.' : 'Error! The user interface for member account "{screenName}" could not be updated.', array('{screenName}' => MHtml::wrapInTag($model->screenName, 'strong'))));
                 Yii::log(W3::t('system', 'Could not save attributes of the {model} model. Model ID: {modelId}. Method called: {method}.', array('{model}' => get_class($model), '{modelId}' => $model->id, '{method}' => __METHOD__ . '()')), 'error', 'w3');
             }
         }
     }
     // display the update form
     $this->render($this->action->id, array('model' => $model, 'pkIsPassed' => $pkIsPassed));
 }
コード例 #8
0
ファイル: notFound.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Member not found'));
MUserFlash::setTopError(Yii::t('hint', 'The requested member does not exist.'));
MLinkList::set('sidebar', array('links' => array(array('text' => Yii::t('link', 'List of members'), 'url' => array('list'), 'icon' => 'grip-solid-horizontal', 'visible' => false), array('text' => Yii::t('link', 'Grid of members'), 'url' => array('grid'), 'icon' => 'calculator', 'visible' => Yii::app()->user->checkAccess($this->id . '/grid')), array('text' => Yii::t('link', 'Create a new member'), 'url' => array('create'), 'icon' => 'plus', 'visible' => Yii::app()->user->checkAccess($this->id . '/create')))));
MUserFlash::setSidebarInfo(Yii::t('hint', 'The requested member was deleted, inactivated or did not exist. Try to browse or search among all members.'));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('text' => Yii::t('link', 'Members'), 'url' => array($this->id . '/' . $this->defaultAction), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/' . $this->defaultAction)))));
コード例 #9
0
ファイル: WUserFlash.php プロジェクト: megabr/web3cms
 /**
  * User flash messages displayed in the 'top' part of the page,
  * between header and the main part.
  */
 public function topSummary()
 {
     if (MUserFlash::hasTopSuccess() || MUserFlash::hasTopInfo() || MUserFlash::hasTopError()) {
         $data = array('success' => MUserFlash::getTopSuccess(), 'info' => MUserFlash::getTopInfo(), 'error' => MUserFlash::getTopError());
         $this->render('wUserFlash/topSummary', $data);
     }
 }
コード例 #10
0
ファイル: login.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Login'));
MUserFlash::setTopError(_CHtml::errorSummary($form));
MUserFlash::setSidebarInfo(Yii::t('hint', 'Hint: You may login with <tt>demo/demo</tt> or <tt>admin/admin</tt>.'));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('url' => array($this->action->id), 'active' => true))));
?>
<div class="w3-main-form-box ui-widget-content ui-corner-all">

<?php 
echo _CHtml::beginForm('', 'post', array('class' => 'w3-main-form')) . "\n";
echo _CHtml::activeHiddenField($form, 'loginWithField') . "\n";
?>

<div class="w3-form-row w3-first">
  <div class="w3-form-row-label"><?php 
echo _CHtml::activeLabelEx($form, $form->getLoginWithField());
?>
</div>
  <div class="w3-form-row-input">
    <?php 
echo _CHtml::activeTextField($form, $form->getLoginWithField(), array('class' => 'w3-input-text ui-widget-content ui-corner-all')) . "\n";
?>
  </div>
  <div class="clear">&nbsp;</div>
</div>
<div class="w3-form-row">
  <div class="w3-form-row-label"><?php 
echo _CHtml::activeLabelEx($form, 'password');
?>
</div>
コード例 #11
0
ファイル: show.php プロジェクト: megabr/web3cms
?>
</div>
  <div class="w3-detail-row-value"><?php 
echo CHtml::encode($model->id);
?>
</div>
  <div class="clear">&nbsp;</div>
</div>
<div class="w3-detail-row">
  <div class="w3-detail-row-label"><?php 
echo CHtml::encode($model->getAttributeLabel('content'));
?>
</div>
  <div class="w3-detail-row-value"><?php 
echo CHtml::encode($model->content);
?>
</div>
  <div class="clear">&nbsp;</div>
</div>

</div>

<?php 
if ($model->isOwner() || Yii::app()->user->checkAccess(User::MANAGER) || Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
    MUserFlash::setSidebarInfo(Yii::t('hint', 'Company transaction history is open for owner, manager and administrator only.'));
    ?>
<div class="w3-between-boxes">&nbsp;</div>

<?php 
    $this->widget('application.components.WGrid', array('displayButtonClose' => true, 'importantRowsBottom' => array(array(array('align' => 'right', 'colspan' => 2, 'content' => Yii::t('math', 'Total')), array('align' => 'right', 'content' => CHtml::encode(MCurrency::format($debit))), array('align' => 'right', 'content' => CHtml::encode(MCurrency::format($credit))), array('align' => 'right', 'content' => CHtml::encode(MCurrency::format($balance))))), 'maxRow' => count($gridRows), 'minRow' => count($gridRows) >= 1 ? 1 : 0, 'rows' => $gridRows, 'sColumns' => array(array('title' => Yii::t('t', 'Date')), array('title' => Yii::t('t', 'Description')), array('title' => Yii::t('payment', 'Debit')), array('title' => Yii::t('payment', 'Credit[accounting]')), array('title' => Yii::t('payment', 'Balance'))), 'sGridId' => 'w3TransactionGrid', 'title' => CHtml::encode(Yii::t('t', 'Transaction history')), 'totalRecords' => count($gridRows)));
}
コード例 #12
0
ファイル: TimeController.php プロジェクト: megabr/web3cms
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'list' page.
  */
 public function actionDelete()
 {
     $model = $this->loadModel();
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         if ($model->delete()) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The time record number {id} has been successfully deleted.', array('{id}' => MHtml::wrapInTag($model->id, 'strong'))));
             // go to the controller default page
             $this->redirect(array($this->id . '/'));
         } else {
             // set error message
             MUserFlash::setTopError(Yii::t('hint', 'Error! The time record number {id} could not be deleted.', array('{id}' => MHtml::wrapInTag($model->id, 'strong'))));
             Yii::log(W3::t('system', 'Could not delete the {model} model. Model ID: {modelId}. Method called: {method}.', array('{model}' => get_class($model), '{modelId}' => $model->id, '{method}' => __METHOD__ . '()')), 'error', 'w3');
         }
     }
     // render the view file
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #13
0
ファイル: error.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Error {errorCode}', array('{errorCode}' => $error['code'])));
MUserFlash::setTopError($error['message']);
MUserFlash::setSidebarInfo(Yii::t('hint', 'Some useful links will be added here soon.'));
$this->widget('application.components.WContentHeader', array('displayBreadcrumbs' => false));
コード例 #14
0
ファイル: grid.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Grid of time records'));
MUserFlash::setSidebarInfo(Yii::t('hint', 'Required: {authRoles}.', array(4, '{authRoles}' => implode(', ', array(Yii::t('t', User::CLIENT_T), Yii::t('t', User::CONSULTANT_T), Yii::t('t', User::MANAGER_T), Yii::t('t', User::ADMINISTRATOR_T))))));
MLinkList::set('sidebar', array('links' => array(array('text' => Yii::t('link', 'View as list'), 'url' => array('list'), 'icon' => 'grip-solid-horizontal', 'visible' => false), array('text' => Yii::t('link', 'Time report'), 'url' => array('report'), 'visible' => Yii::app()->user->checkAccess($this->id . '/report')), array('text' => Yii::t('link', 'Add a time record'), 'url' => array('create'), 'icon' => 'plus', 'visible' => Yii::app()->user->checkAccess($this->id . '/create')))));
$this->widget('application.components.WContentHeader', array('afterLabel' => false, 'breadcrumbs' => array(array('url' => array($this->action->id), 'active' => true))));
$this->widget('application.components.WPreItemActionBar', array('links' => array(array('dropDown' => array('links' => $allCompany), 'text' => CHtml::encode($companyLinkText), 'options' => array('title' => Yii::t('t', 'Company'))), array('dropDown' => array('links' => $allProject), 'text' => CHtml::encode($projectLinkText), 'options' => array('title' => Yii::t('t', 'Project'))), array('dropDown' => array('links' => $allTask, 'width' => 440), 'text' => CHtml::encode($taskLinkText), 'options' => array('title' => Yii::t('t', 'Task'))), array('dropDown' => array('links' => $allManager), 'text' => CHtml::encode($managerLinkText), 'options' => array('title' => Yii::t('t', 'Manager'))), array('dropDown' => array('links' => $allConsultant), 'text' => CHtml::encode($consultantLinkText), 'options' => array('title' => Yii::t('t', 'Consultant'))))));
$this->widget('application.components.WGrid', array('columns' => array(array('title' => CHtml::encode($sort->resolveLabel('company'))), array('title' => CHtml::encode($sort->resolveLabel('project'))), array('title' => CHtml::encode($sort->resolveLabel('task'))), array('title' => CHtml::encode($sort->resolveLabel('manager'))), array('title' => CHtml::encode($sort->resolveLabel('consultant'))), array('title' => CHtml::encode($sort->resolveLabel('timeDate'))), array('title' => CHtml::encode($sort->resolveLabel('spentMinute'))), array('title' => CHtml::encode($sort->resolveLabel('billedMinute'))), array('title' => CHtml::encode($sort->resolveLabel('title'))), array('title' => CHtml::encode(Yii::t('t', 'Actions')))), 'columnsModel' => array(array('name' => 'company', 'width' => 85), array('name' => 'project', 'width' => 85), array('name' => 'task', 'width' => 85), array('name' => 'manager', 'width' => 75), array('name' => 'consultant', 'width' => 75), array('name' => 'timeDate', 'width' => 70, 'align' => 'right'), array('name' => 'spentMinute', 'width' => 35), array('name' => 'billedMinute', 'width' => 35), array('name' => 'title', 'width' => 94), array('name' => 'actions', 'width' => 59, 'sortable' => false)), 'pages' => $pages, 'rowNum' => TimeController::GRID_PAGE_SIZE, 'rows' => $gridRows, 'sColumns' => array(array('title' => $sort->link('company')), array('title' => $sort->link('project')), array('title' => $sort->link('task')), array('title' => $sort->link('manager')), array('title' => $sort->link('consultant')), array('title' => $sort->link('timeDate')), array('title' => $sort->link('spentMinute')), array('title' => $sort->link('billedMinute')), array('title' => $sort->link('title')), array('title' => Yii::t('t', 'Actions'))), 'sortname' => 'timeDate', 'sortorder' => 'desc', 'url' => Yii::app()->createUrl($this->id . '/gridData', $_GET)));
コード例 #15
0
ファイル: index.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Migration tool'));
MLayout::hideSidebars();
$this->widget('application.components.WContentHeader', array('displayBreadcrumbs' => false));
if (!empty($message)) {
    MUserFlash::setTopSuccess($message);
} else {
    ?>
<div class="w3-main-form-box ui-widget-content ui-corner-all">

<?php 
    echo _CHtml::beginForm('', 'post', array('class' => 'w3-main-form')) . "\n";
    ?>

<div class="w3-form-row w3-first">
  <div class="w3-form-row-input w3-form-row-2columns w3-center">
    <?php 
    echo _CHtml::submitButton(Yii::t('link', 'Migrate from our old Project Management System'), array('class' => 'w3-input-button ui-state-default ui-corner-all')) . "\n";
    ?>
  </div>
  <div class="clear">&nbsp;</div>
</div>

<?php 
    echo _CHtml::endForm();
    ?>

</div><!-- w3-main-form-box -->

<?php 
コード例 #16
0
ファイル: update.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Edit time record'));
MUserFlash::setTopError(_CHtml::errorSummary($model));
MUserFlash::setSidebarInfo(Yii::t('hint', 'Required: {authRoles}.', $model->invoiceId >= 1 ? array(1, '{authRoles}' => implode(', ', array(Yii::t('t', User::ADMINISTRATOR_T)))) : array(2, '{authRoles}' => implode(', ', array(Yii::t('t', User::MANAGER_T), Yii::t('t', User::ADMINISTRATOR_T))))));
MLinkList::set('sidebar', array('links' => array(array('text' => Yii::t('link', 'Show time record'), 'url' => array('show', 'id' => $model->id), 'icon' => 'zoomin', 'visible' => Yii::app()->user->checkAccess($this->id . '/show')), array('text' => Yii::t('link', 'Delete time record'), 'url' => array('delete', 'id' => $model->id), 'icon' => 'trash', 'visible' => Yii::app()->user->checkAccess($this->id . '/delete', array('model' => $model))), array('text' => Yii::t('link', 'List of time records'), 'url' => array('list'), 'icon' => 'grip-solid-horizontal', 'visible' => false), array('text' => Yii::t('link', 'Grid of time records'), 'url' => array('grid'), 'icon' => 'calculator', 'visible' => Yii::app()->user->checkAccess($this->id . '/grid')), array('text' => Yii::t('link', 'Create a new time record'), 'url' => array('create'), 'icon' => 'plus', 'visible' => Yii::app()->user->checkAccess($this->id . '/create')))));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('text' => Yii::t('link', 'Time records'), 'url' => array($this->id . '/' . $this->defaultAction), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/' . $this->defaultAction)), array('text' => Yii::t('link', '"{title}" time record', array('{title}' => $model->title)), 'url' => array('show', 'id' => $model->id), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/show')), array('url' => array($this->action->id, 'id' => $model->id), 'active' => true))));
echo $this->renderPartial('_form', array('model' => $model, 'update' => true));
コード例 #17
0
ファイル: TaskController.php プロジェクト: megabr/web3cms
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdate()
 {
     if (($model = $this->loadModel(array('with' => array('allConsultant2Task')))) === null) {
         // model not found
         MUserFlash::setTopError(Yii::t('modelNotFound', $this->id));
         $this->redirect($this->getGotoUrl());
     }
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     // whether data is passed
     if (isset($_POST['Task'])) {
         // collect user input data
         $model->attributes = $_POST['Task'];
         if (!isset($_POST['Task']['companyId'])) {
             // set company based on the project
             if ($model->projectId >= 1) {
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`companyPriority` ASC, `t`.`id` ASC";
                 if (($company2Project = Company2Project::model()->findByAttributes(array('projectId' => $model->projectId), $criteria)) !== null) {
                     $model->companyId = $company2Project->companyId;
                 } else {
                     $model->companyId = 0;
                 }
             } else {
                 $model->companyId = 0;
             }
         }
         if ($model->projectId >= 1 && empty($model->hourlyRate)) {
             // set project's hourly rate
             if (($project = Project::model()->findByPk($model->projectId)) !== null) {
                 $model->hourlyRate = $project->hourlyRate;
             }
         }
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['User2Task'])) {
                 // assigned consultants
                 $hasConsultant = isset($model->allConsultant2Task[0]->id);
                 if (!$hasConsultant) {
                     $model->allConsultant2Task = array(0 => new User2Task('create'));
                     $model->allConsultant2Task[0]->taskId = $model->id;
                 }
                 foreach ($model->allConsultant2Task as $consultant2Task) {
                     // collect user input data
                     $consultant2Task->attributes = $_POST['User2Task'];
                     // at the crossroads: which action is expected to be performed
                     if ($hasConsultant && empty($consultant2Task->userId)) {
                         // un-assigned associated record
                         $consultant2Task->delete();
                     } else {
                         // validate and create/update record
                         $consultant2Task->save();
                     }
                 }
             }
             if (($managers2Task = User2Task::model()->findAllByAttributes(array('taskId' => $model->id, 'role' => User2Task::MANAGER))) !== array()) {
                 // delete existing relation(s) between task and manager
                 foreach ($managers2Task as $manager2Task) {
                     $manager2Task->delete();
                 }
             }
             if ($model->projectId >= 1) {
                 // new relation between task and manager
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
                 if (($user2Project = User2Project::model()->findByAttributes(array('projectId' => $model->projectId, 'role' => User2Project::MANAGER), $criteria)) !== null) {
                     $user2Task = new User2Task('create');
                     $user2Task->userId = $user2Project->userId;
                     $user2Task->taskId = $model->id;
                     $user2Task->role = User2Task::MANAGER;
                     $user2Task->save();
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" task record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     if (!isset($model->allConsultant2Task[0])) {
         // new associated consultant
         $model->allConsultant2Task = array(0 => new User2Task('create'));
         $model->allConsultant2Task[0]->taskId = $model->id;
         $model->allConsultant2Task[0]->role = User2Task::CONSULTANT;
     }
     // prepare model data for the form
     $model->estimateH = floor($model->estimateMinute / 60);
     $model->estimateM = fmod($model->estimateMinute, 60);
     // render the view file
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #18
0
ファイル: updateInterface.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Change interface'));
MUserFlash::setTopError(_CHtml::errorSummary($model));
if (Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
    MUserFlash::setSidebarInfo(Yii::t('hint', 'Required: {authRoles}.', array(1, '{authRoles}' => implode(', ', array(Yii::t('t', User::ADMINISTRATOR_T))))));
}
MLinkList::set('sidebar', array('links' => array(array('text' => Yii::t('link', 'Show my profile'), 'url' => !$pkIsPassed ? array('show') : array('show', 'id' => $model->id), 'icon' => 'person', 'visible' => $model->isMe), array('text' => Yii::t('link', 'Edit my profile'), 'url' => !$pkIsPassed ? array('update') : array('update', 'id' => $model->id), 'icon' => 'pencil', 'visible' => $model->isMe), array('text' => Yii::t('link', 'Show member'), 'url' => array('show', 'id' => $model->id), 'icon' => 'person', 'visible' => !$model->isMe && Yii::app()->user->checkAccess($this->id . '/show')), array('text' => Yii::t('link', 'Edit member\'s profile'), 'url' => array('update', 'id' => $model->id), 'icon' => 'pencil', 'visible' => !$model->isMe && Yii::app()->user->checkAccess($this->id . '/update')), array('text' => Yii::t('link', 'List of members'), 'url' => array('list'), 'icon' => 'grip-solid-horizontal', 'visible' => false), array('text' => Yii::t('link', 'Grid of members'), 'url' => array('grid'), 'icon' => 'calculator', 'visible' => Yii::app()->user->checkAccess($this->id . '/grid')), array('text' => Yii::t('link', 'Create a new member'), 'url' => array('create'), 'icon' => 'plus', 'visible' => Yii::app()->user->checkAccess($this->id . '/create')))));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('text' => Yii::t('link', 'Members'), 'url' => array($this->id . '/'), 'active' => false), array('text' => Yii::t('link', 'My profile'), 'url' => $pkIsPassed ? array('show', 'id' => $model->id) : array('show'), 'visible' => $model->isMe), array('text' => Yii::t('link', '"{screenName}" member', array('{screenName}' => $model->screenName)), 'url' => array('show', 'id' => $model->id), 'visible' => !$model->isMe), array('url' => $model->isMe && !$pkIsPassed ? array($this->action->id) : array($this->action->id, 'id' => $model->id), 'active' => true))));
?>
<div class="w3-main-form-box ui-widget-content ui-corner-all">

<?php 
echo _CHtml::beginForm('', 'post', array('class' => 'w3-main-form')) . "\n";
?>

<div class="w3-form-row w3-first">
  <div class="w3-form-row-input">
    <div class="w3-form-row-text">
      <?php 
echo _CHtml::activeRadioButtonList($model, 'interface', $model->getAttributeData('interface'), array('template' => '<div style="float: left; height: 145px; text-align: center; width: 160px;">{jqueryUIScreenshot}<br/>{input}&nbsp;{label}</div>', 'separator' => "\n")) . "\n";
?>
    </div>
  </div>
  <div class="clear">&nbsp;</div>
</div>
<div class="w3-form-row w3-last">
  <div class="w3-form-row-input w3-form-row-2columns w3-center">
    <div class="w3-form-row-text">
      <?php 
echo Yii::t('hint', '{saveButton} or {cancelLink}', array('{saveButton}' => _CHtml::submitButton(Yii::t('link', 'Apply selected user interface'), array('class' => 'w3-input-button w3-button-big ui-state-default ui-corner-all')), '{cancelLink}' => CHtml::link(Yii::t('link', 'Cancel[form]'), $model->isMe && !$pkIsPassed ? array('show') : array('show', 'id' => $model->id)))) . "\n";
コード例 #19
0
ファイル: LoginForm.php プロジェクト: megabr/web3cms
 /**
  * Authenticates the password.
  * This is the 'authenticate' validator as declared in rules().
  */
 public function authenticate($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $identity = new _CUserIdentity($this->{self::getLoggingWithField()}, $this->password);
         $identity->authenticate();
         switch ($identity->errorCode) {
             case _CUserIdentity::ERROR_NONE:
                 // if user is already logged in
                 if (!Yii::app()->user->isGuest) {
                     // log user out from the current account. i want to sleep well, do you? ;)
                     Yii::app()->user->logout();
                     if (!Yii::app()->getSession()->getIsStarted()) {
                         // restore http session. this is necessary for login
                         Yii::app()->getSession()->open();
                     }
                 }
                 // remember for 30 days. makes sence only if auto-login is allowed
                 $duration = Yii::app()->user->allowAutoLogin && $this->rememberMe ? 3600 * 24 * 30 : 0;
                 // log user in and save in session all appended data
                 Yii::app()->user->login($identity, $duration);
                 // set user preferences (for welcome message, and so on)
                 if (isset(Yii::app()->user->interface) && !empty(Yii::app()->user->interface)) {
                     // set user preferred interface
                     W3::setInterface(Yii::app()->user->interface);
                 }
                 if (isset(Yii::app()->user->language) && !empty(Yii::app()->user->language)) {
                     // set user preferred language
                     W3::setLanguage(Yii::app()->user->language);
                 }
                 break;
             case _CUserIdentity::ERROR_USERNAME_INVALID:
                 if (self::getLoggingWithField() === 'username') {
                     $this->addError('username', Yii::t('t', 'Username is incorrect.'));
                 } else {
                     if (self::getLoggingWithField() === 'email') {
                         $this->addError('email', Yii::t('t', 'Email is incorrect.'));
                     } else {
                         if (self::getLoggingWithField() === 'usernameOrEmail') {
                             $this->addError('usernameOrEmail', Yii::t('t', 'Username or email is incorrect.'));
                         }
                     }
                 }
                 break;
             case _CUserIdentity::ERROR_ACCOUNT_IS_INACTIVE:
                 // set the error message
                 MUserFlash::setTopError(Yii::t('hint', 'We are sorry, but your member account is marked as "inactive". Inactive member accounts are temporarely inaccessible. {contactLink}.', array('{contactLink}' => CHtml::link(Yii::t('link', 'Contact us'), array('site/contact')))));
                 // add to username (first field in the login form) error css class
                 // and make the validate() to fail
                 $attribute = self::getLoggingWithField();
                 $attribute !== 'username' && $attribute !== 'email' && $attribute !== 'usernameOrEmail' && ($attribute = 'username');
                 $this->addError($attribute, '');
                 break;
             case _CUserIdentity::ERROR_IS_NOT_ADMINISTRATOR:
                 // set the error message
                 MUserFlash::setTopError(Yii::t('hint', 'We are sorry, but your access type is {accessType}. Required access type: {requiredAccessType}.', array('{accessType}' => Yii::app()->controller->var->userAccessType, '{requiredAccessType}' => Yii::t('t', User::ADMINISTRATOR_T))));
                 unset(Yii::app()->controller->var->userAccessType);
                 // we do not need this any more
                 // add to username (first field in the login form) error css class
                 // and make the validate() to fail
                 $attribute = self::getLoggingWithField();
                 $attribute !== 'username' && $attribute !== 'email' && $attribute !== 'usernameOrEmail' && ($attribute = 'username');
                 $this->addError($attribute, '');
                 break;
             case _CUserIdentity::ERROR_PASSWORD_INVALID:
             default:
                 $this->addError('password', Yii::t('t', 'Password is incorrect.'));
                 break;
         }
     }
 }
コード例 #20
0
ファイル: create.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Create a new project'));
MUserFlash::setTopError(_CHtml::errorSummary($model));
MLinkList::set('sidebar', array('links' => array(array('text' => Yii::t('link', 'List of projects'), 'url' => array('list'), 'icon' => 'grip-solid-horizontal', 'visible' => false), array('text' => Yii::t('link', 'Grid of projects'), 'url' => array('grid'), 'icon' => 'calculator', 'visible' => Yii::app()->user->checkAccess($this->id . '/grid')))));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('text' => Yii::t('link', 'Projects'), 'url' => array($this->id . '/' . $this->defaultAction), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/' . $this->defaultAction)), array('url' => array($this->action->id), 'active' => true))));
echo $this->renderPartial('_form', array('model' => $model, 'update' => false));
コード例 #21
0
ファイル: CompanyController.php プロジェクト: megabr/web3cms
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadModel(array('with' => array('allUser2Company', 'allLocation')));
     if ($model === null) {
         // model not found
         MUserFlash::setTopError(Yii::t('modelNotFound', $this->id));
         $this->redirect($this->getGotoUrl());
     }
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     // whether data is passed
     if (isset($_POST['Company'])) {
         // collect user input data
         $model->attributes = $_POST['Company'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['User2Company'])) {
                 // assigned users
                 $hasUser = isset($model->allUser2Company[0]->id);
                 if (!$hasUser) {
                     $model->allUser2Company = array(0 => new User2Company('create'));
                     $model->allUser2Company[0]->companyId = $model->id;
                 }
                 foreach ($model->allUser2Company as $user2Company) {
                     // collect user input data
                     $user2Company->attributes = $_POST['User2Company'];
                     $user2Company->position = 'owner';
                     // at the crossroads: which action is expected to be performed
                     if ($hasUser && empty($user2Company->userId)) {
                         // un-assigned associated record
                         $user2Company->delete();
                     } else {
                         // validate and create/update record
                         $user2Company->save();
                     }
                 }
             }
             if (isset($_POST['Location'])) {
                 // assigned locations
                 if (!isset($model->allLocation[0]->id)) {
                     $model->allLocation = array(0 => new Location('create'));
                 }
                 foreach ($model->allLocation as $location) {
                     // collect user input data
                     $location->attributes = $_POST['Location'];
                     // validate and create/update record
                     if ($location->save()) {
                         $location2Record = new Location2Record('create');
                         $location2Record->locationId = $location->id;
                         $location2Record->record = get_class($model);
                         $location2Record->recordId = $model->id;
                         $location2Record->save();
                     }
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" company record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     if (!isset($model->allUser2Company[0])) {
         // new associated user
         $model->allUser2Company = array(0 => new User2Company('create'));
         $model->allUser2Company[0]->companyId = $model->id;
     }
     if (!isset($model->allLocation[0])) {
         // new associated location
         $model->allLocation = array(0 => new Location('create'));
     }
     // display the update form
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #22
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'show' page.
  */
 public function actionUpdate()
 {
     if (($model = $this->loadModel()) === null) {
         // model not found
         MUserFlash::setTopError(Yii::t('modelNotFound', $this->id));
         $this->redirect($this->getGotoUrl());
     }
     // explicitly set model scenario to be current action
     //$model->setScenario($this->action->id);
     // whether data is passed
     if (isset($_POST['CompanyPayment'])) {
         // collect user input data
         $model->attributes = $_POST['CompanyPayment'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The company payment record number "{paymentNumber}" has been updated.', array('{paymentNumber}' => MHtml::wrapInTag(empty($model->paymentNumber) ? $model->id : $model->paymentNumber, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     }
     $this->render($this->action->id, array('model' => $model));
 }
コード例 #23
0
ファイル: contact.php プロジェクト: megabr/web3cms
<?php

MParams::setPageLabel(Yii::t('page', 'Contact us'));
MUserFlash::setTopError(_CHtml::errorSummary($contact));
MUserFlash::setSidebarInfo(Yii::t('hint', 'If you have business inquiries or other questions, please fill out this form to contact us. Thank you.'));
$this->widget('application.components.WContentHeader', array('breadcrumbs' => array(array('url' => array($this->action->id), 'active' => true))));
?>
<div class="w3-main-form-box ui-widget-content ui-corner-all">

<?php 
echo _CHtml::beginForm('', 'post', array('class' => 'w3-main-form')) . "\n";
?>

<div class="w3-form-row w3-first">
  <div class="w3-form-row-label"><?php 
echo _CHtml::activeLabelEx($contact, 'name');
?>
</div>
  <div class="w3-form-row-input">
    <?php 
echo _CHtml::activeTextField($contact, 'name', array('class' => 'w3-input-text ui-widget-content ui-corner-all', 'maxlength' => 128)) . "\n";
?>
  </div>
  <div class="clear">&nbsp;</div>
</div>
<div class="w3-form-row">
  <div class="w3-form-row-label"><?php 
echo _CHtml::activeLabelEx($contact, 'email');
?>
</div>
  <div class="w3-form-row-input">