/** * 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)); }
<?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));
/** * 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; }
<?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)))));
/** * 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)); }
/** * 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; } } }
/** * 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)); }
/** * 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)); }
/** * 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)); }
<?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"> </div> </div> <div class="w3-form-row"> <div class="w3-form-row-label"><?php echo _CHtml::activeLabelEx($form, 'password'); ?> </div>
<?php MParams::setPageLabel($model->isMe ? Yii::t('page', 'Edit my profile') : Yii::t('page', 'Edit member\'s profile')); MUserFlash::setTopError(_CHtml::errorSummary($model)); MUserFlash::setTopError(_CHtml::errorSummary($model->details)); if (Yii::app()->user->checkAccess(User::ADMINISTRATOR)) { // FIXME: remove - deprecated 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', 'Change interface'), 'url' => !$pkIsPassed ? array('updateInterface') : array('updateInterface', 'id' => $model->id), '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', 'Change interface'), 'url' => array('updateInterface', 'id' => $model->id), 'visible' => !$model->isMe && Yii::app()->user->checkAccess($this->id . '/updateInterface')), 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 . '/' . $this->defaultAction), 'active' => false, 'visible' => Yii::app()->user->checkAccess($this->id . '/' . $this->defaultAction)), 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 && Yii::app()->user->checkAccess($this->id . '/show')), 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"; ?> <?php if (Yii::app()->user->checkAccess(User::ADMINISTRATOR)) { ?> <div class="w3-form-row w3-first"> <div class="w3-form-row-label"><?php echo _CHtml::activeLabelEx($model, 'isActive'); ?> </div> <div class="w3-form-row-input"> <?php echo _CHtml::activeDropDownList($model, 'isActive', $model->getAttributeData('isActive'), array('class' => 'w3-input-text ui-widget-content ui-corner-all')) . "\n"; ?> <br/><?php
/** * 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)); }
<?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));
<?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"> </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">