/**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $auditEventsListView = new AuditEventsModalListView($controller->getId(), $controller->getModule()->getId(), 'AuditEvent', $dataProvider, 'modal');
     $view = new ModalView($controller, $auditEventsListView);
     return $view->render();
 }
Пример #2
0
 /**
  * Checks whether the Web user is allowed to perform the specified action.
  * @param CWebUser $user the user object
  * @param CController $controller the controller currently being executed
  * @param CAction $action the action to be performed
  * @param string $ip the request IP address
  * @param string $verb the request verb (GET, POST, etc.)
  * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user
  */
 public function isUserAllowed($user, $controller, $action, $ip, $verb)
 {
     try {
         /*
         			$sesMod = $user->getState('modType');
         			$oCurMod = $controller->getModule();
         			if( $oCurMod != NULL ){
         				if( ($oCurMod->getId() == 'ad' && $sesMod == 'pub') ||
         					($oCurMod->getId() == 'pub' && $sesMod == 'ad') )
         					
         				throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'pub_ad_mod_confused'));	
         			}
         */
         echo 'user access';
         return false;
         $aPerm = $user->perm;
         $aAction = $aPerm[$controller->getId()]['_p'];
         if (is_array($aAction) && in_array(strtolower($action->getId()), $aAction)) {
             return true;
         } else {
             throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
         }
     } catch (Exception $e) {
         throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
     }
 }
 /**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider, $action)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $modalListLinkProvider = new UserDetailsModalListLinkProvider('users', 'default', 'details');
     $usersListView = new UsersByModelModalListView($controller->getId(), $controller->getModule()->getId(), $action, 'User', $modalListLinkProvider, $dataProvider, 'modal');
     $view = new ModalView($controller, $usersListView);
     return $view->render();
 }
Пример #4
0
 public function renderMailContent(CController $controller)
 {
     if ($this->templatePath) {
         $controller->renderPartial($this->getMailTemplatePath(), $this->getParamsToRender());
     } else {
         echo '';
     }
 }
Пример #5
0
 public function renderMessage($view, array $data = array())
 {
     $controller = new \CController('SmsSender');
     $viewPath = \Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'views';
     $viewFile = $controller->resolveViewFile($view, $viewPath, $viewPath);
     $body = $controller->renderInternal($viewFile, $data, true);
     return $body;
 }
 public function generate()
 {
     $model = new MainAccountModel();
     $model->save();
     $ccc = new CController('context');
     $fileName = tempnam(sys_get_temp_dir(), "asd");
     $fileName .= ".html";
     $htmlOutput = $ccc->renderInternal(Yii::getPathOfAlias("application.views.templates") . '/index.php', $model->attributes, true);
     file_put_contents($fileName, $htmlOutput);
     return $fileName;
 }
Пример #7
0
 /**
  * @param CController $controller
  * @param $stickySearchKey
  * @param RedBeanModel $model
  * @return mixed
  */
 public static function resolveBreadCrumbViewForDetailsControllerAction(CController $controller, $stickySearchKey, RedBeanModel $model)
 {
     assert('is_string($stickySearchKey)');
     if (ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset') !== null && StickySearchUtil::getDataByKey($stickySearchKey) != null) {
         $stickyLoadUrl = Yii::app()->createUrl($controller->getModule()->getId() . '/' . $controller->getId() . '/renderStickyListBreadCrumbContent', array('stickyKey' => $stickySearchKey, 'stickyOffset' => ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset'), 'stickyModelId' => $model->id));
     } else {
         $stickyLoadUrl = null;
     }
     $className = static::resolveStickyDetailsAndRelationsBreadCrumbViewClassName();
     return new $className($controller->getId(), $controller->getModule()->getId(), static::resolveBreadcrumbLinks($model), $controller->getModule()->getModuleLabelByTypeAndLanguage('Plural'), $stickyLoadUrl);
 }
Пример #8
0
 public function testDefaultProperties()
 {
     $app = new TestApplication();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $c = new CController('test/subtest');
     $this->assertEquals($c->id, 'test/subtest');
     $this->assertEquals($c->filters(), array());
     $this->assertEquals($c->actions(), array());
     $this->assertNull($c->action);
     $this->assertEquals($c->defaultAction, 'index');
     $this->assertEquals($c->viewPath, $app->viewPath . DIRECTORY_SEPARATOR . 'test/subtest');
     $this->setExpectedException('CHttpException');
     $c->missingAction('index');
 }
Пример #9
0
 /**
  * 最终跳转处理
  * @param type $msg 提示信息
  * @param type $jumpurl 跳转url
  * @param type $wait 等待时间
  * @param int $type 消息类型 0或1
  */
 private static function _jump($msg = "", $jumpurl = "", $wait = 3, $type = 0)
 {
     $data = array('msg' => $msg, 'jumpurl' => $jumpurl, 'wait' => $wait, 'type' => $type);
     $data['title'] = $type == 1 ? "提示信息" : "错误信息";
     if (empty($jumpurl)) {
         if ($type == 1) {
             $data['jumpurl'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "javascript:window.close();";
         } else {
             $data['jumpurl'] = "javascript:history.back(-1);";
         }
     }
     $cc = new CController('showmessage');
     $cc->renderPartial("/showMessage", $data);
     exit;
 }
 public static function handle(CExceptionEvent $event)
 {
     $exception = $event->exception;
     if (get_class($exception) == "CHttpException" && $exception->statusCode === 404) {
         $pathParts = explode('/', Yii::app()->getRequest()->getRequestUri());
         $pathPart = array_pop($pathParts);
         $criteria = new CDbCriteria();
         $criteria->addSearchCondition('alias', $pathPart);
         $criteria->limit = 5;
         $models = Article::model()->findAll($criteria);
         $controller = new CController(null);
         $controller->renderPartial('//error/404', array('models' => $models));
         $event->handled = true;
     }
 }
Пример #11
0
 /**
  * Initializes the pager by setting some default property values.
  * @param string $html
  * @param string $title
  * @param mixed $format
  * @param string $orientation
  */
 public function __construct($html, $title = '', $format = 'A4', $orientation = 'P')
 {
     parent::__construct($this->mode, $format, $this->defaultFontSize, $this->defaultFont, $this->marginLeft, $this->marginRight, $this->marginTop, $this->marginBottom, $this->marginHeader, $this->marginFooter, $orientation);
     $controller = new CController('PDF');
     $controller->layout = $this->layouts;
     $html = $controller->renderText($html, true);
     $this->SetCreator($this->creator);
     $this->SetTitle($title);
     if (!UserWeb::instance()->isGuest) {
         $this->SetFooter(sprintf('Berkas dicetak oleh %s, %s||{PAGENO}', UserWeb::instance()->user()->username, date('Y-m-d H:i:s')));
     } else {
         throw new CHttpException(403, 'Anda tidak memiliki otoritas untuk mengakses halaman ini');
     }
     $this->writeHTML($html);
 }
Пример #12
0
 protected function beforeAction($action)
 {
     parent::beforeAction($action);
     if (Yii::app()->user->isGuest) {
         if (isset(Yii::app()->request->cookies['prefLang'])) {
             $sChosenLanguage = Yii::app()->request->cookies['prefLang']->value;
         } else {
             $sPrefferedLang = Yii::app()->request->getPreferredLanguage();
             if ($sPrefferedLang !== false && strpos($sPrefferedLang, "ru") !== false) {
                 $sChosenLanguage = "ru";
             } else {
                 $sChosenLanguage = "uk_ua";
             }
             $cookie = new CHttpCookie('prefLangId', $sChosenLanguage);
             $cookie->expire = time() + 86400 * 7;
             Yii::app()->request->cookies['prefLang'] = $cookie;
         }
     } else {
         $sChosenLanguage = Yii::app()->user->getLanguage();
     }
     switch ($sChosenLanguage) {
         case "ru":
             Yii::app()->language = "ru";
             break;
         default:
             Yii::app()->language = "uk_ua";
     }
     return true;
 }
Пример #13
0
 public function sendRequest($hole, $user)
 {
     if (!$hole->isMoscow) {
         return false;
     }
     $client = $this->client;
     Yii::app()->request->baseUrl = Yii::app()->request->hostInfo;
     $pictures = array();
     foreach ($hole->pictures_fresh as $pict) {
         $pictures[] = array('name' => $pict->filename, 'fileType' => $pict->extension, 'content' => $pict->binary);
     }
     $answer = $client->RequestNew(array('request' => array('hidden' => false, 'informer' => array('name' => $this->name, 'surname' => $this->surname, 'fatherName' => $this->fatherName, 'phoneNumber' => $this->phoneNumber, 'email' => $this->email, 'notifyViaEmail' => $this->notifyViaEmail, 'notifyViaSms' => $this->notifyViaSms, 'address' => array('fullAddress' => $this->address)), 'category' => array('code' => $hole->type->dorogimos_id), 'details' => $this->details, 'address' => array('latitude' => $hole->LATITUDE, 'longitude' => $hole->LONGITUDE, 'fullAddress' => $this->holeAddress, 'webLink' => CController::createUrl('/holes/view', array('id' => $hole->ID))), 'pictures' => $pictures)));
     if ($answer->successful) {
         $holeRequest = new HoleRequests();
         $holeRequest->hole_id = $hole->ID;
         $holeRequest->user_id = $user->id;
         $holeRequest->date_sent = time();
         $holeRequest->response_requestid = $answer->request->requestNumber;
         $holeRequest->type = 'dorogimos';
         $holeRequest->gibdd_id = 0;
         if ($holeRequest->save()) {
             return true;
         }
         //else print_r($holeRequest->errors); die();
     } else {
         $this->errortext = $answer->failReason;
         //print_r($answer); die();
     }
     return false;
 }
Пример #14
0
 public function __construct($id, $module = null)
 {
     parent::__construct($id, $module);
     // If there is a post-request, redirect the application to the provided url of the selected language
     if (isset($_POST['language'])) {
         $lang = $_POST['language'];
         $MultilangReturnUrl = $_POST[$lang];
         $this->redirect($MultilangReturnUrl);
     }
     // Set the application language if provided by GET, session or cookie
     if (isset($_GET['language'])) {
         Yii::app()->language = $_GET['language'];
         Yii::app()->user->setState('language', $_GET['language']);
         $cookie = new CHttpCookie('language', $_GET['language']);
         $cookie->expire = time() + 60 * 60 * 24 * 365;
         // (1 year)
         Yii::app()->request->cookies['language'] = $cookie;
     } else {
         if (Yii::app()->user->hasState('language')) {
             Yii::app()->language = Yii::app()->user->getState('language');
         } else {
             if (isset(Yii::app()->request->cookies['language'])) {
                 Yii::app()->language = Yii::app()->request->cookies['language']->value;
             }
         }
     }
 }
Пример #15
0
 /**
  * (non-PHPdoc)
  * @see yii/CController#filters()
  */
 public function filters()
 {
     return array_merge(array(
         array('SetupFilter'),
         array('SslFilter')
     ), parent::filters());
 }
Пример #16
0
 /**
  * initialize
  */
 function init()
 {
     parent::init();
     if (Yii::app()->getRequest()->getParam('printview')) {
         Yii::app()->layout = 'print';
     }
 }
Пример #17
0
 protected function beforeAction($action)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $this->layout = false;
     }
     return parent::beforeAction($action);
 }
Пример #18
0
 public function actionRegistro()
 {
     $modelAlumnos = new Alumno();
     if (isset($_POST['Alumno'])) {
         try {
             $usuario = new Usuario();
             $usuario->perfil = 3;
             $usuario->nombreUsuario = $_POST['Alumno']['identificacion'];
             $usuario->password = md5($_POST['Alumno']['identificacion']);
             if ($usuario->save()) {
                 $alumno = new Alumno();
                 $alumno->attributes = $_POST['Alumno'];
                 $alumno->idUsuario = $usuario->idUsuario;
                 if (!$alumno->save()) {
                     Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
                 } else {
                     Yii::app()->user->setFlash('alert alert-success', "Alumno  fue creado con éxito");
                     $this->redirect(CController::createUrl('/sitio/index'));
                 }
             } else {
                 Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado");
         }
     }
     $this->render('registroEstudiantes', array('modelAlumnos' => $modelAlumnos));
 }
Пример #19
0
 protected function afterAction($action)
 {
     $time = sprintf('%0.5f', Yii::getLogger()->getExecutionTime());
     $memory = round(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
     echo '<!-- Time: ' . $time . 'ms, memory: ' . $memory . '-->';
     parent::afterAction($action);
 }
Пример #20
0
 protected function afterAction($action)
 {
     parent::afterAction($action);
     if (!$this->readOnly) {
         Yii::app()->unitOfWork->commit();
     }
 }
Пример #21
0
 public function init()
 {
     if (Yii::app()->user->id) {
         Yii::app()->theme = Yii::app()->user->theme;
     }
     parent::init();
 }
Пример #22
0
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     if (isset(Yii::app()->user->usIdent)) {
         // Obtiene la clasificación de los equipos
         $clasificacion = Clasificacion::model()->with('equipos')->findAll(array('order' => 'posicion ASC'));
         Yii::app()->setParams(array('clasificacion' => $clasificacion));
         // Obtiene la información del usuario
         $usuario = Usuarios::model()->with('recursos')->findByPK(Yii::app()->user->usIdent);
         Yii::app()->setParams(array('usuario' => $usuario));
         // Obtiene la información de la mensajeria
         //Saca la lista de los emails recibidos por el usuario y que ademas no los haya leido
         $mensajeria = Emails::model()->findAllByAttributes(array('id_usuario_to' => Yii::app()->user->usIdent, 'leido' => 0));
         $countmens = count($mensajeria);
         Yii::app()->setParams(array('countmens' => $countmens));
         // Obtiene la información de las notificaciones
         //Saca la lista de las notinicaciones recibidas por el usuario y que ademas no haya leido
         $notificaciones = Usrnotif::model()->findAllByAttributes(array('usuarios_id_usuario' => Yii::app()->user->usIdent, 'leido' => 0));
         $countnot = count($notificaciones);
         Yii::app()->setParams(array('countnot' => $countnot));
     }
     Yii::app()->setParams(array('bgclass' => 'bg-estadio-fuera'));
     return true;
 }
Пример #23
0
 public function init()
 {
     parent::init();
     $user = Yii::app()->user;
     $isGuest = $user->getIsGuest();
     $this->topMenu = array(array('label' => 'Home', 'url' => array('dashboard/index')), array('label' => 'Account' . (!$isGuest ? ' (' . Yii::app()->user->name . ')' : ''), 'items' => array(array('label' => 'Logout', 'url' => array('user/logout'), 'visible' => !$isGuest), array('label' => 'Login', 'url' => array('user/login'), 'visible' => $isGuest), array('label' => 'Register', 'url' => array('user/register'), 'visible' => $isGuest))));
 }
Пример #24
0
 function init()
 {
     global $db, $user, $mainframe, $hideMenu;
     $hideMenu = 0;
     $task = Request::getVar("task", "");
     if ($task != "") {
         $cmd = "action{$task}()";
         if (method_exists($this, $cmd)) {
             $this->{$cmd}();
         }
     }
     $db = $this->db = Yii::app()->db;
     Yii::app()->name = "Back end";
     $user = $this->user = Yii::app()->session['userbackend'];
     $mainframe = MainFrame::getInstance($this->db, $this->user);
     parent::init();
     $app = Yii::app();
     if (!$mainframe->isLogin()) {
         $duration = time() + 300;
         // 365 days
     } else {
         $remember_admin = (isset($_COOKIE['remember_admin']) and $_COOKIE['remember_admin'] == 1) ? 1 : 0;
         if ($remember_admin == 1) {
             $duration = time() + 86400 * 30;
         } else {
             $duration = time() + 900;
         }
         // 15 minutes
     }
     $cookie = new CHttpCookie(session_name(), session_id(), array("expire" => $duration));
     $app->getRequest()->getCookies()->add($cookie->name, $cookie);
 }
 public function init()
 {
     parent::init();
     stat_collector::setStamp();
     // stamp
     $this->uid = get_uid();
     $this->is_adm = hasPermissions('tservices');
     // разметка страницы с левым сайдбаром
     $this->layout = '//layouts/content-with-right-sidebar';
     // в сайдбаре вывести фильтр с учётом текущей категории
     $this->getClips()->add('sidebar', $this->widget('TServiceFilter', array(), true));
     // чтобы отрисовать фильтр и опции
     # TODO добиться, чтобы $this->widget('TServiceFilter') и $this->createWidget($this,'TServiceFilter') возвращал один и тот же объект
     $this->filter_widget = $this->createWidget($this, 'TServiceFilter', array());
     // копия, чтобы узнать, какие опции были выбраны
     $prof_id = $this->filter_widget->filter->category ? $this->filter_widget->filter->category : $this->filter_widget->filter->category_group;
     //----------------------------------------------------------------------
     //@todo: возможно нужно общее хранилище собираемых данных
     //в течении работы скрипта с последующей передачей в GA и Adriver?
     GaJsHelper::getInstance()->setTuCategories($this->filter_widget->filter->category_group, $this->filter_widget->filter->category);
     adriver::getInstance()->setTuCategories($this->filter_widget->filter->category_group, $this->filter_widget->filter->category);
     //----------------------------------------------------------------------
     SeoTags::getInstance()->initTserviceList($prof_id, $this->filter_widget->filter->category > 0);
     $this->getClips()->add('header', $this->widget('TServiceNavigation', array('category_group' => $this->filter_widget->filter->category_group, 'category' => $this->filter_widget->filter->category, 'filter_get_params' => $this->filter_widget->getUserFriendlyUrl(false)), true));
     $this->getClips()->add('content_top', $this->widget('TServiceCatalogHeader', array(), true));
     $this->getClips()->add('categories', $this->widget('TServiceCatalogCategories', array('category_group' => $this->filter_widget->filter->category_group, 'filter_get_params' => $this->filter_widget->getUserFriendlyUrl(false)), true));
     // в футере каталога вывести список специализаций фрилансеров
     $this->getClips()->add('footer', $this->widget('TServiceFreelancersCategories', array(), true));
     $tserviceModel = TServiceModel::model();
     $this->counter_users = $tserviceModel->countUsers();
     $this->counter_tu = $tserviceModel->countTservices();
 }
Пример #26
0
 public function init()
 {
     parent::init();
     if (!$this->isLogged()) {
         $this->redirect(array('site/adminLogin'));
     }
 }
Пример #27
0
 public function init()
 {
     parent::init();
     if (Yii::app()->request->getIsAjaxRequest()) {
         $this->layout = '//layouts/clear';
     }
 }
Пример #28
0
 /**
  * Инициализация контроллера
  */
 public function init($action)
 {
     parent::init();
     $this->uid = get_uid(false);
     $this->is_adm = hasPermissions('projects', $this->uid);
     $this->layout = '//layouts/content-with-right-narrow-sidebar';
 }
 public function init()
 {
     // enable the KCFINDER uploads
     $KCFINDER = array('disabled' => false, 'uploadURL' => Yii::app()->baseUrl . "/uploads/", 'uploadDir' => Yii::app()->basePath . "/../uploads/");
     Yii::app()->session['KCFINDER'] = $KCFINDER;
     parent::init();
 }
Пример #30
0
 public function init()
 {
     if (!extension_loaded('apc')) {
         throw new CException('PHP\'s APC extension must be loaded!');
     }
     parent::init();
 }