public function getModuleItems() { $basicModules = array('x2Activity', 'contacts', 'charts', 'accounts', 'opportunities', 'x2Leads', 'quotes', 'products', 'services', 'bugReports', 'users'); $qpg = new QueryParamGenerator(); $criteria = new CDbCriteria(); $criteria->condition = '(name in ' . $qpg->bindArray($basicModules, true) . ' or custom) and visible and moduleType in ("module", "pseudoModule") and name != "document"'; $criteria->params = $qpg->getParams(); $criteria->order = 'menuPosition ASC'; $modules = Modules::model()->findAll($criteria); $modules = array_filter($modules, function ($module) { if ($module->title === 'charts') { $action = 'ReportsChartDashboard'; } else { $action = ucfirst($module->title) . 'Index'; } $authItem = Yii::app()->authManager->getAuthItem($action); return Yii::app()->params->isAdmin || is_null($authItem) || Yii::app()->user->checkAccess($action); }); return array_map(function ($module) { $item = new ModulePanelItem(); $item->module = $module; return $item; }, $modules); }
/** * Change Case status using select-box */ public function actionChangeStatus() { // check if user has permissions to changeStatusCases if (Yii::app()->user->checkAccess('changeStatusCases')) { // verify is request was made via post ajax if (Yii::app()->request->isAjaxRequest && isset($_POST)) { // get Cases object model $model = $this->loadModel($_REQUEST['id']); // set new status $model->status_id = $_POST['changeto']; // validate and save if ($model->save()) { // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseStatusChanged', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id); Logs::model()->saveLog($attributes); // create comment to let then know that some user change the case status $modelComment = new Comments(); $modelComment->comment_date = date("Y-m-d G:i:s"); $modelComment->comment_text = Status::STATUS_COMMENT . ": " . $model->Status->status_id; $modelComment->user_id = Yii::app()->user->id; $modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id; $modelComment->comment_resourceid = $model->case_id; $modelComment->save(false); // prepare email template for each project manager Yii::import('application.extensions.phpMailer.yiiPhpMailer'); $mailer = new yiiPhpMailer(); $subject = Yii::t('email', 'CaseStatusChange') . " - " . $model->case_name; //$Users = Users::model()->with('Clients')->findManagersByProject($model->project_id); $Users = Projects::model()->findAllUsersByProject($model->project_id); $recipientsList = array(); foreach ($Users as $client) { $recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email); } // load template $str = $this->renderPartial('//templates/cases/StatusChanged', array('case' => $model, 'user' => Users::model()->findByPk(Yii::app()->user->id), 'urlToCase' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('cases/view', array('id' => $model->case_id)), 'typeNews' => $model->status_id == Status::STATUS_ACCEPTED || $model->status_id == Status::STATUS_TOREVIEW ? 'buenas' : 'malas', 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true); $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL); $output = Yii::t('cases', 'StatusChanged'); } else { $output = Yii::t('cases', 'StatusError'); } echo $output; Yii::app()->end(); } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } }
/** * Returns theme configuration * @param null $strClass * @return array|mixed */ public function getConfigValues($strClass = null) { $strClass = Yii::app()->theme->name; $arr = array(); $objModule = Modules::model()->findByAttributes(array('module' => $strClass, 'category' => 'theme')); if ($objModule instanceof Modules) { try { $arr = unserialize($objModule->configuration); } catch (Exception $e) { Yii::log("Could not unserialize " . $strClass . " . Error : " . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); return array(); } } return $arr; }
public function activation($page_id = null) { if (!is_null($page_id)) { $module_id = Modules::model()->getModuleIdByCode($this->id); ModulesInPages::model()->addLink($module_id, $page_id); } }
public static function constructMenuArray() { $arrModules = Modules::model()->findAllByAttributes(array('category' => 'CEventCustomer'), array('order' => 'name')); //Get active and inactive $arrModulesMenu = array(); foreach ($arrModules as $module) { try { Yii::import('application.extensions.' . $module->module . '.' . $module->module); $objC = new $module->module(); $arrModulesMenu[] = array('label' => $objC->name, 'url' => array('integration/integration', 'id' => $module->module)); } catch (Exception $e) { Yii::log("Missing widget " . $e, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } } $arrSocialAccountsMenu = array(array('label' => 'Social Accounts', 'linkOptions' => array('class' => 'nav-header')), array('label' => 'Edit Public Accounts', 'url' => array('integration/edit', 'id' => self::SOCIAL))); $arrAmazonMenu = array(); if (Yii::app()->params['SHOW_AMAZON_INTEGRATION'] === '1') { $arrAmazonMenu = array(array('label' => 'Amazon', 'linkOptions' => array('class' => 'nav-header')), array('label' => 'Amazon MWS Settings', 'url' => array('integration/integration', 'id' => 'wsamazon')), array('label' => 'Match Amazon Categories to WS', 'url' => array('integration/amazonmatch')), array('label' => 'Queue for Amazon Tasks', 'url' => array('integration/amazonqueue'))); } $arrEmailMenu = array(array('label' => 'Email Managers', 'linkOptions' => array('class' => 'nav-header'))); $arrFacebookMenu = array(array('label' => 'Facebook', 'linkOptions' => array('class' => 'nav-header')), array('label' => 'Facebook Connect', 'url' => array('integration/edit', 'id' => self::FACEBOOK))); $arrGoogleMenu = array(array('label' => 'Google', 'linkOptions' => array('class' => 'nav-header')), array('label' => 'Google Settings', 'url' => array('integration/edit', 'id' => self::GOOGLE)), array('label' => 'Match Google Categories to WS', 'url' => array('integration/googlematch'))); $arrMenuItems = array_merge($arrSocialAccountsMenu, $arrAmazonMenu, $arrEmailMenu, $arrModulesMenu, $arrFacebookMenu, $arrGoogleMenu); return $arrMenuItems; }
public function actionIndex() { $step = Yii::app()->request->getParam("step", 1); switch ($step) { case 1: $this->render('index'); break; case 2: $this->render('check', array('check' => environmentChecksUpdate::run())); break; case 3: $authGet = Yii::app()->request->getParam("auth", 'sorry'); if (Yii::app()->request->csrfToken != $authGet) { $this->render('check'); } databaseConfiguration::SplitSQL(Yii::app()->getModulePath() . '/update/data/0_4/mysql_update.sql'); $updated = array(); $comments = Comments::model()->findAll(); foreach ($comments as $comment) { if (!in_array($comment->comment_resourceid . "," . $comment->module_id, $updated)) { $module = Modules::model()->findByPk($comment->module_id)->module_className; $modelClass = new $module(); $project = $modelClass::model()->findByPk($comment->comment_resourceid)->project_id; Comments::model()->updateAll(array('project_id' => $project), 'comment_resourceid = :resourceid AND module_id = :moduleid', array(':resourceid' => $comment->comment_resourceid, ':moduleid' => $comment->module_id)); array_push($updated, $comment->comment_resourceid . "," . $comment->module_id); } } $this->render('finish'); break; default: $this->render('index'); break; } }
public function actionSettings($id) { $this->layout = '//layouts/admin'; $model = Modules::model()->findByPk($id); $dbTableData = array(); if (is_object($model)) { $this->pageTitle = 'Управление модулями :: ' . $model->title; $this->breadcrumbs = array('Управление модулями' => array('/admin/default/modules/index'), $model->title); $tables = Yii::app()->db->schema->getTables(); if ($model->models) { $mArr = explode(",", $model->models); if (is_array($mArr) && count($mArr)) { foreach ($mArr as $mName) { $m = new $mName(); if (is_object($m) && isset($tables[$m->tableName()])) { $dbTableData[] = $tables[$m->tableName()]; } } } } /* if(is_array($tables) && isset($tables[$model->tableName()])){ $dbTableData = $tables[$model->tableName()]; }*/ } if (!isset($model) || !is_object($model)) { $this->redirect($_SERVER['HTTP_REFERER']); } $this->render("settings", array('model' => $model, 'dbTableData' => $dbTableData)); }
public function search($searchAttributes, $term) { $selected = Yii::app()->user->getState('project_selected'); if (empty($selected)) { Yii::app()->user->setFlash('GlobalSearchForm', Yii::t('site', 'selectOneProject')); } $items = array(); foreach ($searchAttributes as $key => $value) { array_push($items, $key); } $modules = Modules::model()->findAll(array('condition' => 't.module_name IN ("' . implode('","', $items) . '")')); // array donde se guardaran los resultados $dataproviders = array(); foreach ($modules as $module) { $criteria = new CDbCriteria(); if (in_array($module->module_name, array_keys($this->searchModels))) { foreach ($this->searchModels[$module->module_name] as $attr) { $criteria->compare($attr, $term, true, 'OR'); $criteria->compare('project_id', !empty($selected) ? $selected : -1); } $dataproviders[$module->module_name] = new CActiveDataProvider($module->module_className, array('criteria' => $criteria)); } } return $dataproviders; }
public function displayAccessWarning() { if (Yii::app()->isCommonSSL) { return; } $access_warning_cookie = Yii::app()->request->cookies['access_warning']; if ($access_warning_cookie === null || $access_warning_cookie->value !== 'false') { $objModule = Modules::model()->LoadByName('wsaccesswarning'); if (!$objModule) { Yii::import('ext.wsaccesswarning.models.*'); $arrDefaultConfig = $this->getAdminModel()->getDefaultConfiguration(); $objModule = new Modules(); $objModule->module = 'wsaccesswarning'; $objModule->category = 'extension'; $objModule->name = 'Site Access Warning'; $objModule->version = 1; $objModule->active = 0; $objModule->configuration = serialize($arrDefaultConfig); $objModule->save(); } if ($objModule->active) { $arrConfig = $objModule->GetConfigValues(); $globalScript = sprintf("var accessWarningMessage = %s;", json_encode($this->_transformMessageForDisplay($arrConfig['message']))); // No HTML tags are allowed in the button caption so we encode to HTML entities. $globalScript .= sprintf("var accessWarningButtonCaption = %s;", json_encode(CHtml::encode($arrConfig['button_caption']))); $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $cs = Yii::app()->getClientScript(); $cs->registerScript('_', $globalScript, CClientScript::POS_HEAD); $cs->registerCssFile($assets . '/css/wsaccesswarning.css'); $cs->registerScriptFile($assets . '/thirdparty/carhartl-jquery-cookie/jquery.cookie.js'); $cs->registerScriptFile($assets . '/js/wsaccesswarning.js'); } } }
public function menuCheck($attr, $params = array()) { $this->{$attr}; $this->scenario = 'menu'; if (sizeof(Modules::model()->findAllByAttributes(array('name' => $this->name))) > 0) { $this->addError('name', 'That name is not available.'); } }
public function beforeControllerAction($controller, $action) { if (parent::beforeControllerAction($controller, $action)) { $controller->module_id = Modules::model()->getModuleIdByCode($this->id); // this method is called before any module controller action is performed // you may place customized code here return true; } else { return false; } }
/** * Creates a new model. * @return create view */ public function actionCreate() { // create Logs object model $model = new Logs(); // if Logs form exist if (isset($_POST['Logs'])) { // set form elements to Logs model attributes $model->attributes = $_POST['Logs']; // find module_name before save $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id))); // set finded module_id to module->module_id $model->module_id = $module->module_id; // save without validate $model->save(false); } }
/** * Initializes the controller. */ public function init() { parent::init(); if (!isset(Yii::app()->request->cookies['sel_lang'])) { Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', 'en_us'); Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value); } else { if (isset($_REQUEST['lc']) && !empty($_REQUEST['lc'])) { Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', $_REQUEST['lc']); } if (in_array(strtolower(Yii::app()->request->cookies['sel_lang']->value), Yii::app()->params['languages'])) { Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value); } } if (isset($_GET['infoproject']) && !empty($_GET['infoproject']) && Users::model()->verifyUserInProject((int) Yii::app()->request->getParam("infoproject", 0), Yii::app()->user->id)) { Yii::app()->user->setState('project_selected', Yii::app()->request->getParam("infoproject", 0)); Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->project_name); $this->redirect(Yii::app()->createUrl('site')); } $avoid = array('companies'); if (Yii::app()->user->getState('project_selected') == null && Yii::app()->controller->id != null && !empty(Yii::app()->controller->ActionParams['id']) && !in_array(Yii::app()->controller->id, $avoid)) { // Finding module class name $criteria = new CDbCriteria(); $criteria->compare('module_name', Yii::app()->controller->id); $module = Modules::model()->find($criteria); if (isset($module->module_className) && class_exists($module->module_className)) { // create class instance $className = $module->module_className; $instance = new $className(); // finding model record $criteria = new CDbCriteria(); $criteria->compare($instance->getMetaData()->tableSchema->primaryKey, Yii::app()->controller->ActionParams['id']); $model = $instance->find($criteria); if ($model !== null) { // finding model relations $relations = $model->getMetaData()->relations; if (array_key_exists("Projects", $relations) || $module->module_className == "Projects") { if (Users::model()->verifyUserInProject($model->project_id, Yii::app()->user->id)) { Yii::app()->user->setState('project_selected', $model->project_id); Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk($model->project_id)->project_name); } } } } } }
public static function supportedModules(CDbCriteria $criteria = null) { $basicModules = array('x2Activity', 'topics', 'contacts', 'charts', 'accounts', 'opportunities', 'x2Leads', 'quotes', 'products', 'services', 'bugReports', 'users'); $qpg = new QueryParamGenerator(); $newCriteria = new CDbCriteria(); $newCriteria->condition = '(name in ' . $qpg->bindArray($basicModules, true) . ' or custom) and visible and moduleType in ("module", "pseudoModule") and name != "document"'; $newCriteria->params = $qpg->getParams(); $newCriteria->order = 'menuPosition ASC'; if ($criteria) { $newCriteria->mergeWith($criteria); $criteria = $newCriteria; } else { $criteria = $newCriteria; } $modules = Modules::model()->findAll($criteria); return $modules; }
/** * See if we have any events to fire */ public function actionIndex() { $criteria = new CDbCriteria(); $criteria->compare('active', 1); $criteria->compare('category', 'CEvent', true, 'AND'); $objModules = Modules::model()->findAll($criteria); foreach ($objModules as $objModule) { //Find and our tasks (one of each type this cron cycle) $criteria = new CDbCriteria(); $criteria->select = 'action'; $criteria->distinct = true; $criteria->compare('controller', $objModule->module); $objTaskTypes = TaskQueue::model()->findAll($criteria); Yii::import('ext.' . $objModule->module . "." . $objModule->module); $component = new $objModule->module(); $component->init(); //Run init on module first foreach ($objTaskTypes as $objType) { //Locate a task of this type $objTask = TaskQueue::model()->findByAttributes(array('module' => 'integration', 'controller' => $objModule->module, 'action' => $objType->action)); Yii::log("Found TaskQueue item " . $objTask->controller . " " . $objTask->action, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $actionName = "OnAction" . ucfirst($objTask->action); $objEvent = new CEventTaskQueue(get_class($this), $objTask->data_id, $objTask->product_id); Yii::log("Cron action " . $actionName . " on object " . print_r($objEvent, true), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); //Run the action and get a true/false if it was successful $retVal = $component->{$actionName}($objEvent); if ($retVal) { Yii::log("Successfully processed by Amazon, so deleting task", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $objTask->delete(); //Successfully ran, so delete entry } else { Yii::log("Still waiting on Amazon, will check again next time", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $objTask->modified = new CDbExpression('NOW()'); $objTask->save(); } } } //Create a Download Orders event to force any other subsystems to check for new orders if (date("i") % 10 == 0) { $objEvent = new CEventOrder('CronController', 'onDownloadOrders'); _xls_raise_events('CEventOrder', $objEvent); } }
public function actionUpdate($id = false, $page = 1) { $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id; if ($role_id != 7 || $role_id == 7 && $id == 1) { $pages = new Pages(); if (!empty($id) && Pages::model()->existsPage($id)) { $active = Modules::model()->getActiveModule($id); $model = $pages->findByPk($id); if (isset($_POST['Pages'])) { if ($model->validate()) { $old_file_id = $model->image_id; if ($_POST['Pages']['image_id'] == 'NULL') { $_POST['Pages']['image_id'] = ''; } $model->attributes = $_POST['Pages']; if ($model->save()) { if ((int) $_POST['Pages']['image_id']) { Files::model()->saveTempFile((int) $_POST['Pages']['image_id']); } elseif ($_POST['Pages']['image_id'] == '') { Files::model()->deleteFile($old_file_id, 'page'); } if ($old_file_id != $model->image_id) { Files::model()->deleteFile($old_file_id, 'page'); } // Yii::app()->user->setFlash('message','<p style="color:green;">Сохранено</p>'); $this->redirect(YII::app()->baseUrl . '/admin.php?r=pages/update&id=' . $id); } else { // Yii::app()->user->setFlash('message','<p style="color:red;">Ошибка</p>'); } } } $image = Pages::model()->getImage($id, 'page'); $this->pageTitle = 'Редактирование раздела — ' . $model->name; $this->render('update', array('model' => $model, 'name' => $model->getPageNameById($id), 'active' => $active, 'image' => $image, 'page' => $page)); } else { $this->redirect(Yii::app()->request->baseUrl); } } else { $this->redirect(Yii::app()->baseUrl . '/admin.php?r=pages/access'); } }
/** * Return the enabled shipping modules. * * @return array Returns an associative array indexed on the shipping * module ID (xlsws_module.id) where each value is an array with 2 keys: * module and component. The module property is the CActiveRecord * xlsws_module instance. The component is the corresponding application * component (IApplicationComponent) instance. * * @throws Exception When no shipping providers are available. */ protected static function getAvailableShippingProviders($checkoutForm) { Yii::log("Contacting each live shipping module", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); $shippingModules = Modules::model()->shipping()->findAll(); $arrShippingProvider = array(); foreach ($shippingModules as $objModule) { if (empty($checkoutForm->shippingCountryCode) === true && $objModule->module !== 'storepickup') { continue; } if (_xls_get_conf('DEBUG_SHIPPING', false)) { Yii::log("Attempting to get the component for module " . $objModule->module, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); } $objComponent = Yii::app()->getComponent($objModule->module); if ($objComponent === null) { Yii::log("Error missing component for module " . $objModule->module, 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); continue; } // The shipping component needs data from the checkout form. $objComponent->setCheckoutForm($checkoutForm); // Restrictions may apply to some modules. if ($objComponent->Show === false) { Yii::log("Module is not shown " . $objModule->module, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); continue; } $arrShippingProvider[$objModule->id]['module'] = $objModule; $arrShippingProvider[$objModule->id]['component'] = $objComponent; } // If we have no providers in our list, it means either the // restrictions have cancelled them out or they aren't turned on in // the first place. if (count($arrShippingProvider) === 0) { Yii::log("No shipping methods apply to this order, cannot continue!", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__); throw new Exception(Yii::t('checkout', 'Website configuration error. No shipping methods apply to this order. Cannot continue.')); } return $arrShippingProvider; }
/** * Parse an associationType field and resolve the model name * @param string $model Model type to resolve * @return string Model's name */ public static function parseModelName($model) { $customModule = Modules::model()->findByAttributes(array('custom' => 1, 'name' => $model)); if ($customModule) { //$model = $customModule->title; $model = Modules::itemDisplayName($customModule->name); $model = strtolower($model); } else { switch ($model) { case 'Product': $model .= 's'; break; case 'Quote': $model .= 's'; break; case 'Opportunity': $model = str_replace('y', 'ies', $model); break; } $requestedModel = $model; $model = Modules::displayName(false, ucfirst($model)); $model = strtolower($model); if (empty($model)) { // If the model type couldn't be resolved, check for special cases // of models without a dedicated module if ($requestedModel === 'AnonContact') { $model = 'anonymous contact'; } else { if ($requestedModel === 'Campaign') { $model = 'campaign'; } } } } return Yii::t('app', $model); }
public function actionOrder() { $order = Yii::app()->getRequest()->getPost('order'); if (isset($order)) { $arrOrder = explode(",", $order); Modules::model()->updateAll(array('sort_order' => null), 'category = :cat', array(':cat' => 'shipping')); $ct = 1; foreach ($arrOrder as $id) { Modules::model()->updateByPk($id, array('sort_order' => $ct++)); } } else { Yii::app()->clientScript->registerCoreScript('jquery'); Yii::app()->clientScript->registerCoreScript('jquery.ui'); Yii::app()->clientScript->registerCssFile("http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css"); $this->registerAsset("js/sortable.js"); $criteria = new CDbCriteria(); $criteria->addCondition("category='shipping'"); $criteria->addCondition("active=1"); $criteria->addCondition("name IS NOT NULL"); $criteria->order = 'sort_order'; $model = Modules::model()->findAll($criteria); $this->render("order", array('model' => $model)); } }
/** * Displays a particular model. * @return string with success message */ public function actionchangeStatus() { // check if user has permissions to changeStatusInvoices if (Yii::app()->user->checkAccess('changeStatusInvoices')) { // verify is request was made via post ajax if (Yii::app()->request->isAjaxRequest && isset($_POST)) { // get Invoice object model $model = $this->loadModel(); // set new status $model->status_id = $_POST['changeto']; // validate and save if ($model->save()) { // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'InvoiceStatusChanged', 'log_resourceid' => $model->invoice_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id); Logs::model()->saveLog($attributes); // create comment to let then know that some user change the invoice status $modelComment = new Comments(); $modelComment->comment_date = date("Y-m-d G:i:s"); $modelComment->comment_text = "StatusChanged: " . $model->Status->status_id; $modelComment->user_id = Yii::app()->user->id; $modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id; $modelComment->comment_resourceid = $model->invoice_id; $modelComment->save(false); $output = Yii::t('invoices', 'StatusChanged'); } else { $output = Yii::t('invoices', 'StatusError'); } echo $output; Yii::app()->end(); } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } } else { throw new CHttpException(403, Yii::t('site', '403_Error')); } }
/** * Export all data * * This method is used to export all of the data from the software as a CSV */ public function actionExport() { $modelList = array('Admin' => array('name' => Yii::t('admin', 'Admin Settings'), 'count' => 1)); $modules = Modules::model()->findAll(); foreach ($modules as $module) { $name = ucfirst($module->name); if ($name != 'Document') { $controllerName = $name . 'Controller'; if (file_exists('protected/modules/' . $module->name . '/controllers/' . $controllerName . '.php')) { Yii::import("application.modules.{$module->name}.controllers.{$controllerName}"); $controller = new $controllerName($controllerName); $model = $controller->modelClass; if (class_exists($model)) { $recordCount = X2Model::model($model)->count(); if ($recordCount > 0) { // Only display modules we actually have data for... $modelList[$model] = array('name' => Yii::t('app', $module->title), 'count' => $recordCount); } } } } } $extraModels = array('Fields', 'Dropdowns', 'FormLayout'); foreach ($extraModels as $model) { if (class_exists($model)) { $fieldCount = X2Model::model($model)->count(); if ($fieldCount > 0) { $modelList[$model] = array('name' => Yii::t('app', $model), 'count' => $fieldCount); } } } $this->render('export', array('modelList' => $modelList)); }
/** * @return array names of models associated with each module */ public static function getNamesOfModelsOfModules() { $moduleNames = array_map(function ($record) { return $record->name; }, Modules::model()->findAll(array('select' => 'name'))); $models = array(); foreach ($moduleNames as $name) { $modelName = X2Model::getModelName($name); if ($modelName && is_subclass_of($modelName, 'X2Model')) { $models[] = $modelName; } } return $models; }
<div class="span3"> <?php echo $form->dropDownList($objCart, 'cart_type', array(CartType::awaitpayment => 'Unpaid', CartType::order => 'Paid')); ?> </div> </div> <div class="row-fluid"> <div class="span3"> <?php echo $form->labelEx($model, 'payment_module'); ?> </div> <div class="span3"> <?php echo $form->dropDownList($model, 'payment_module', CHtml::listData(Modules::model()->findAllByAttributes(array('category' => 'payment', 'active' => 1), array('order' => 'name')), 'module', 'name')); ?> </div> </div> <div class="row-fluid"> <div class="span3"> <?php echo $form->labelEx($model, 'payment_data'); ?> </div> <div class="span3"> <?php echo $form->textField($model, 'payment_data'); ?> </div>
'; foreach ($adminFlashes as $index => $message) { $themeCss .= "\n div.flash-message-{$index} {\n top: " . (string) ($index * $flashTotalHeight) . "px;\n }"; } $cs->registerCss('applyTheme', $themeCss, 'screen', CClientScript::POS_HEAD); } // $themeCss .= $theme2Css; //$cs->registerCss('applyTheme2', $theme2Css, 'screen', CClientScript::POS_HEAD); mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); $module = Yii::app()->controller->id; $menuItems = array(); if ($isGuest) { $menuItems = array(array('label' => Yii::t('app', 'Login'), 'url' => array('/site/login'))); } $modules = Modules::model()->findAll(array('condition' => 'visible="1"')); usort($modules, function ($a, $b) { $aPos = $a->menuPosition === null ? INF : (int) $a->menuPosition; $bPos = $b->menuPosition === null ? INF : (int) $b->menuPosition; if ($aPos < $bPos) { return -1; } elseif ($aPos > $bPos) { return 1; } else { return 0; } }); $standardMenuItems = array(); foreach ($modules as $moduleItem) { if (($isAdmin || $moduleItem->adminOnly == 0) && $moduleItem->name != 'users') { if ($moduleItem->name !== 'document') {
/** * Creates a new model. */ public function actionCreate() { // create Comments Object $model = new Comments(); // if Comments form exist if (isset($_POST['Comments'])) { // set form elements to Comments model attributes $model->attributes = $_POST['Comments']; $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id))); // set module_id finded to model $model->module_id = $module->module_id; $project = Yii::app()->user->getState('project_selected'); $model->project_id = $project; // validate and save if ($model->save()) { // create an instance of file uploaded $image = CUploadedFile::getInstancesByName('Comment'); // if file upload exist if (count($image > 0)) { // for each file uploaded for ($i = 0; $i < count($image); $i++) { // create an Document object $modeldocs = new Documents(); $modeldocs->image = $image[$i]; if (!$modeldocs->image->getError()) { // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime()) $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime()); // set the extension file uploaded $extension = $modeldocs->image->getExtensionName(); // if no error saving file if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) { $modeldocs->project_id = $project; $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30); $modeldocs->document_description = $model->comment_text; $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension; $modeldocs->document_revision = '1'; $modeldocs->document_uploadDate = date("Y-m-d"); $modeldocs->document_type = $modeldocs->image->getType(); $modeldocs->document_baseRevision = date('dmYHis'); $modeldocs->user_id = Yii::app()->user->id; $modeldocs->comment_id = $model->primaryKey; // save file uploaded as document if ($modeldocs->save()) { Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk')); } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors()); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError')); } } else { Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors')); } } } // save log $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project); Logs::model()->saveLog($attributes); // find project managers to sent comment via mail $recipientsList = array(); $ProjectManagers = Projects::model()->findManagersByProject($project); $managersArray = array(); foreach ($ProjectManagers as $manager) { $managersArray['email'] = $manager->user_email; $managersArray['name'] = $manager->CompleteName; array_push($recipientsList, $managersArray); } // find task owners to send comment via mail if ($module->module_name == 'tasks') { $collaborators = Projects::model()->findAllUsersByProject($project); $ColaboratorsArray = array(); foreach ($collaborators as $colaborator) { $ColaboratorsArray['email'] = $colaborator->user_email; $ColaboratorsArray['name'] = $colaborator->CompleteName; // avoid to repeat email address if (!in_array($ColaboratorsArray, $recipientsList)) { array_push($recipientsList, $ColaboratorsArray); } } } // finding resource title switch ($module->module_name) { case "budgets": $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title; break; case "invoices": $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number; break; case "expenses": $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name; break; case "documents": $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name; break; case "milestones": $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title; break; case "cases": $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name; break; case "tasks": $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name; break; default: $resourceModelTitle = "{empty}"; break; } // get project information $project = Projects::model()->findByPk($project); // prepare template to send via email $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true); Yii::import('application.extensions.phpMailer.yiiPhpMailer'); $mailer = new yiiPhpMailer(); $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name); $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL); } else { Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment')); } } $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey))); }
/** * @var string $widgetType * @return array associative array with widget class names as keys and widget labels as values */ public static function getWidgetSubtypeOptions($widgetType) { static $cache = array(); if (!isset($cache[$widgetType])) { $widgetSubtypes = self::getWidgetSubtypes($widgetType); $cache[$widgetType] = array_combine($widgetSubtypes, array_map(function ($widgetType) { $jsonPropertiesStruct = $widgetType::getJSONPropertiesStructure(); return $jsonPropertiesStruct['label']; }, $widgetSubtypes)); // add custom module summary pseudo-subtypes if ($widgetType === 'profile') { $customModules = Modules::model()->getCustomModules(true); foreach ($customModules as $module) { $modelName = ucfirst($module->name); if ($module->name !== 'document' && class_exists($modelName)) { // prefix widget class name with custom module model name and a delimiter $cache[$widgetType][$modelName . '::TemplatesGridViewProfileWidget'] = Yii::t('app', '{modelName} Summary', array('{modelName}' => Modules::displayName(true, $module->name))); } } } } return $cache[$widgetType]; }
public function actionSearch() { ini_set('memory_limit', -1); $term = $_GET['term']; if (substr($term, 0, 1) != "#") { /*$contactsCriteria = new CDbCriteria(); $contactsCriteria->compare('firstName', $term, true, 'OR'); $contactsCriteria->compare('lastName', $term, true, 'OR'); $contactsCriteria->compare('name', $term, true, 'OR'); $contactsCriteria->compare('backgroundInfo', $term, true, 'OR'); $contactsCriteria->compare('email', $term, true, 'OR'); $contactsCriteria->compare('phone', $term, true, 'OR'); if(is_numeric($term)){ $temp=$term; $first=substr($temp,0,3); $second=substr($temp,3,3); $third=substr($temp,6,4); $contactsCriteria->compare('phone', "($first) $second-$third", true, 'OR'); $contactsCriteria->compare('phone', "$first-$second-$third", true, 'OR'); $contactsCriteria->compare('phone', "$first $second $third", true, 'OR'); $contactsCriteria->compare('phone2', "($first) $second-$third", true, 'OR'); $contactsCriteria->compare('phone2', "$first-$second-$third", true, 'OR'); $contactsCriteria->compare('phone2', "$first $second $third", true, 'OR'); } $contacts=Contacts::model()->findAll($contactsCriteria); $actionsCriteria=new CDbCriteria(); $actionsCriteria->compare('actionDescription',$term,true,'OR'); $actions=Actions::model()->findAll($actionsCriteria); $accountsCriteria=new CDbCriteria(); $accountsCriteria->compare("name",$term,true,"OR"); $accountsCriteria->compare("description",$term,true,"OR"); $accountsCriteria->compare('tickerSymbol',$term,true,'OR'); $accounts=Accounts::model()->findAll($accountsCriteria); $quotesCriteria=new CDbCriteria(); $quotesCriteria->compare("name",$term,TRUE,"OR"); $quotes=Quote::model()->findAll($quotesCriteria); $disallow=array( 'contacts', 'actions', 'accounts', 'quotes', );*/ $modules = Modules::model()->findAllByAttributes(array('searchable' => 1)); $comparisons = array(); foreach ($modules as $module) { $module->name == 'products' ? $type = ucfirst('Product') : ($type = ucfirst($module->name)); $module->name == 'quotes' ? $type = ucfirst('Quote') : ($type = $type); $criteria = new CDbCriteria(); $fields = Fields::model()->findAllByAttributes(array('modelName' => $type, 'searchable' => 1)); $temp = array(); foreach ($fields as $field) { $temp[] = $field->id; $criteria->compare($field->fieldName, $term, true, "OR"); } $arr = CActiveRecord::model($type)->findAll($criteria); $comparisons[$type] = $temp; $other[$type] = $arr; } $high = array(); $medium = array(); $low = array(); $records = array(); $regEx = "/{$term}/i"; foreach ($other as $key => $recordType) { $fieldList = $comparisons[$key]; foreach ($recordType as $otherRecord) { foreach ($fieldList as $field) { $fieldRecord = Fields::model()->findByPk($field); $fieldName = $fieldRecord->fieldName; if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) { switch ($fieldRecord->relevance) { case "High": if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) { $high[] = $otherRecord; } break; case "Medium": if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) { $medium[] = $otherRecord; } break; case "Low": if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) { $low[] = $otherRecord; } break; default: $low[] = $otherRecord; } } } } } $records = array_merge($high, $medium); $records = array_merge($records, $low); $records = Record::convert($records, false); $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()))); $this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term)); } else { $results = new CActiveDataProvider('Tags', array('criteria' => array('condition' => 'tag="' . $term . '"'))); $this->render('searchTags', array('tags' => $results)); } }
/** * Return a new instance of the payment method's subform model object * or null if the method does not have a subform * * @return null */ public function getPaymentSubFormModel() { $arrModuleForms = $this->getAlternativePaymentMethodsThatUseSubForms(); if (isset($this->paymentProvider) && array_key_exists($this->paymentProvider, $arrModuleForms)) { $objPaymentModule = Modules::model()->findByPk($this->paymentProvider); $objComponent = Yii::app()->getComponent($objPaymentModule->module); if (isset($objComponent->subform)) { $paymentSubform = $objComponent->subform; $paymentSubFormModel = new $paymentSubform(); } } else { $paymentSubFormModel = null; } return $paymentSubFormModel; }
* California 95067, USA. or at email address contact@x2engine.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * X2Engine" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by X2Engine". *****************************************************************************************/ $heading = Yii::t('contacts', '{module} Lists', array('{module}' => Modules::displayName(false))); $this->pageTitle = $heading; $opportunityModule = Modules::model()->findByAttributes(array('name' => 'opportunities')); $accountModule = Modules::model()->findByAttributes(array('name' => 'accounts')); $menuOptions = array('all', 'lists', 'create', 'createList'); if ($opportunityModule->visible && $accountModule->visible) { $menuOptions[] = 'quick'; } $this->insertMenu($menuOptions); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('contacts-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <?php foreach (Yii::app()->user->getFlashes() as $key => $message) { echo '<div class="flash-' . $key . '">' . $message . "</div>\n"; } ?> <?php
public function titleUpdate($old_title, $new_title) { if (sizeof(Modules::model()->findAllByAttributes(array('name' => $new_title))) == 0 && $old_title != $new_title) { Yii::app()->db->createCommand()->update('x2_modules', array('title' => $new_title), 'title=:old_title', array(':old_title' => $old_title)); } }