function sendit_subscription() { $sendit = new Actions(); $sendit->NewSubscriber(); wp_die(); // this is required to terminate immediately and return a proper response }
public static function TriggerDisplayPage(array $param) { $action = new Actions(); if ($action->DisplayPage($param[0])) { exit; } }
public function testMergeActions() { $contact = $this->contact('testAnyone'); $action = new Actions(); $action->actionDescription = "TEST"; $action->visibility = 1; $action->associationType = "contacts"; $action->associationId = $contact->id; $action->save(); $model = new Contacts(); foreach ($contact->attributes as $key => $val) { if ($key != 'id' && $key != 'nameId') { $model->{$key} = $val; } } $model->save(); $this->assertEquals(0, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $model->id))->queryScalar()); $this->assertEquals(1, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $contact->id))->queryScalar()); $mergeData = $model->mergeActions($contact, true); $this->assertEquals(1, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $model->id))->queryScalar()); $this->assertEquals(0, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $contact->id))->queryScalar()); $model->unmergeActions($contact->id, $mergeData); $this->assertEquals(1, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $contact->id))->queryScalar()); $this->assertEquals(0, Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where('associationType = "contacts" AND associationId = :id', array(':id' => $model->id))->queryScalar()); }
public function execute(&$params) { $model = new Actions(); $model->type = 'note'; $model->complete = 'Yes'; $model->associationId = $params['model']->id; $model->associationType = $params['model']->module; $model->actionDescription = $this->parseOption('comment', $params); $model->assignedTo = $this->parseOption('assignedTo', $params); $model->completedBy = $this->parseOption('assignedTo', $params); if (empty($model->assignedTo) && $params['model']->hasAttribute('assignedTo')) { $model->assignedTo = $params['model']->assignedTo; $model->completedBy = $params['model']->assignedTo; } if ($params['model']->hasAttribute('visibility')) { $model->visibility = $params['model']->visibility; } $model->createDate = time(); $model->completeDate = time(); if ($model->save()) { return array(true, Yii::t('studio', 'View created action: ') . $model->getLink()); } else { $errors = $model->getErrors(); return array(false, array_shift($errors)); } }
public function renderInput(CModel $model, $attribute, array $htmlOptions = array()) { $action = new Actions(); $action->setAttributes($model->getAttributes(), false); $defaultOptions = array('id' => $this->resolveId($attribute)); $htmlOptions = X2Html::mergeHtmlOptions($defaultOptions, $htmlOptions); return preg_replace('/Actions(\\[[^\\]]*\\])/', get_class($this->formModel) . '$1', $action->renderInput($attribute, $htmlOptions)); }
public function delete($id) { $db = new Db($this->subgridConfig, $this->statusVariables); $fields = $this->subgridConfig->fields(); $curData = $db->fetchRow($id); foreach ($fields as $field) { $fieldObject = $this->subgridConfig->fieldObject($field); $fieldObject->beforeDelete($id, $curData); } $sql = "\n DELETE\n " . $this->subgridConfig->tableName() . "\n FROM\n " . $this->subgridConfig->tableName() . "\n " . $db->joinQuery() . "\n WHERE\n " . $this->subgridConfig->tableName() . ".`" . $this->subgridConfig->idField() . "` = :id\n "; $params = array('id' => $id); $callables = $this->subgridConfig->beforeDelete(); if ($callables) { if (is_array($callables) && !is_callable($callables)) { foreach ($callables as $callable) { call_user_func($callable, $params['id']); } } else { call_user_func($callables, $params['id']); } } ipDb()->execute($sql, $params); if ($this->subgridConfig->isMultilingual()) { $sql = "\n DELETE\n\n FROM\n " . $this->subgridConfig->languageTableName() . "\n WHERE\n " . $this->subgridConfig->languageTableName() . ".`" . $this->subgridConfig->languageForeignKeyField() . "` = :id\n "; ipDb()->execute($sql, $params); } $callables = $this->subgridConfig->afterDelete(); if ($callables) { if (is_array($callables) && !is_callable($callables)) { foreach ($callables as $callable) { call_user_func($callable, $params['id']); } } else { call_user_func($callables, $params['id']); } } //remove records in child grids foreach ($fields as $field) { $fieldObject = $this->subgridConfig->fieldObject($field); $fieldObject->afterDelete($id, $curData); if ($field['type'] == 'Grid') { $childStatusVariables = Status::genSubgridVariables($this->statusVariables, $field['gridId'], $id); $subActions = new Actions(new Config($field['config']), $childStatusVariables); $childConfig = new Config($field['config']); $db = new Db($childConfig, $childStatusVariables); $where = $db->buildSqlWhere(); $sql = "\n SELECT\n `" . $childConfig->idField() . "`\n FROM\n " . $childConfig->tableName() . "\n WHERE\n {$where}\n "; $idsToDelete = ipDb()->fetchColumn($sql); foreach ($idsToDelete as $idToDelete) { $subActions->delete($idToDelete); } } } }
/** * @param array $instance * @return string|void * @description Widget Backend */ public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } $post_types = get_post_types(); $objAction = new Actions(); $data['post_types'] = $post_types; $data['title'] = $title; $data['obj'] = $this; $data['post_type'] = get_post_types(); echo $objAction->theme('nv_new_posts_widget', $data); }
/** * Makes sure adding a user happens without errors * * @link http://issues.thebuggenie.com/thebuggenie/issues/2494 * * @covers thebuggenie\core\modules\configuration\Actions::runAddUser * @dataProvider addUserRequestProvider */ public function testRunAddUser($username, $buddyname, $email, $password, $group_id) { \b2db\Core::resetMocks(); $scope = $this->getMockBuilder('thebuggenie\\core\\entities\\Scope')->setMethods(array('hasUsersAvailable'))->getMock(); $scope->method('hasUsersAvailable')->willReturn(true); \thebuggenie\core\framework\Context::setScope($scope); $request = new \thebuggenie\core\framework\Request(); $request->setParameter('username', $username); $request->setParameter('buddyname', $buddyname); $request->setParameter('email', $email); $request->setParameter('password', $password); $request->setParameter('password_repeat', $password); $request->setParameter('group_id', $group_id); $usertablestub = $this->getMockBuilder('b2db\\Table')->setMethods(array('isUsernameAvailable'))->getMock(); $userscopestablestub = $this->getMockBuilder('b2db\\Table')->getMock(); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\UserScopes', $userscopestablestub); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\User', $usertablestub); \b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\Users', $usertablestub); $usertablestub->method('isUsernameAvailable')->will($this->returnValue(true)); // Expect action to verify that username is available $usertablestub->expects($this->once())->method('isUsernameAvailable')->with($username); $userscopestablestub->expects($this->once())->method('countUsers'); $this->object->runAddUser($request); $userobject = \b2db\Core::getTable('thebuggenie\\core\\entities\\tables\\Users')->getLastMockObject(); // Expect action to set correct user properties $this->assertEquals($userobject->getUsername(), $username); $this->assertEquals($userobject->getBuddyname(), $buddyname); $this->assertEquals($userobject->getRealname(), $username); $this->assertEquals($userobject->getEmail(), $email); }
private function addNormalUser($aRequest) { $aUser = array(); foreach ($this->aUserParams as $sParam) { switch ($sParam) { case "username": $aUser[$sParam] = strtolower($aRequest[$sParam]); break; case "logo": $aUser[$sParam] = Actions::uploadPhotos($aRequest['logo'], 'logo'); break; default: $aUser[$sParam] = $aRequest[$sParam]; break; } } $aUser['date_registered'] = date('Y-m-d h:i:s'); $aUser['age'] = $aRequest['date_of_birth']; //Hashing the password to be saved encrypted $aUser['password'] = Hash::make($aUser['password']); DB::table('users')->insert($aUser); $dIdUser = DB::table('users')->where(array('username' => $aUser['username']))->get(array('id_user')); DB::table('user_rating')->insert(array('id_user' => $dIdUser[0]->id_user, 'likes_count' => 0)); echo "You've registered successfully!"; return redirect()->intended('/'); }
public function execute(array $gvSelection) { $updatedRecordsNum = Actions::changeCompleteState('uncomplete', $gvSelection); if ($updatedRecordsNum > 0) { self::$successFlashes[] = Yii::t('app', '{updatedRecordsNum} action' . ($updatedRecordsNum === 1 ? '' : 's') . ' uncompleted', array('{updatedRecordsNum}' => $updatedRecordsNum)); } return $updatedRecordsNum; }
/** * Processes the specified route * @exits * @return null */ public function processRequest() { Actions::trigger("{$this->routeKey}AjaxStart"); $response = call_user_func($this->action); Actions::trigger("{$this->routeKey}AjaxEnd"); echo json_encode($response); die; }
public function renderAttribute($attr, $makeLinks = true, $textOnly = true, $encode = true) { if ($attr === 'text') { $action = Actions::model(); $action->actionDescription = $this->{$attr}; return $action->renderAttribute('actionDescription', $makeLinks, $textOnly, $encode); } }
public function execute(&$params) { $options = $this->config['options']; $action = new Actions(); $action->subject = $this->parseOption('subject', $params); $action->dueDate = $this->parseOption('dueDate', $params); $action->actionDescription = $this->parseOption('description', $params); $action->priority = $this->parseOption('priority', $params); $action->visibility = $this->parseOption('visibility', $params); if (isset($params['model'])) { $action->assignedTo = $this->parseOption('assignedTo', $params); } // if(isset($this->config['attributes'])) // $this->setModelAttributes($action,$this->config['attributes'],$params); if ($action->save()) { return array(true, Yii::t('studio', "View created action: ") . $action->getLink()); } else { $errors = $action->getErrors(); return array(false, array_shift($errors)); } // if($this->parseOption('reminder',$params)) { // $notif=new Notification; // $notif->modelType='Actions'; // $notif->createdBy=Yii::app()->user->getName(); // $notif->modelId=$model->id; // if($_POST['notificationUsers']=='me'){ // $notif->user=Yii::app()->user->getName(); // }else{ // $notif->user=$model->assignedTo; // } // $notif->createDate=$model->dueDate-($_POST['notificationTime']*60); // $notif->type='action_reminder'; // $notif->save(); // if($_POST['notificationUsers']=='both' && Yii::app()->user->getName()!=$model->assignedTo){ // $notif2=new Notification; // $notif2->modelType='Actions'; // $notif2->createdBy=Yii::app()->user->getName(); // $notif2->modelId=$model->id; // $notif2->user=Yii::app()->user->getName(); // $notif2->createDate=$model->dueDate-($_POST['notificationTime']*60); // $notif2->type='action_reminder'; // $notif2->save(); // } // } }
/** * Creates the widget. */ public function run() { list($assignedToCondition, $params) = Actions::model()->getAssignedToCondition(); $total = Yii::app()->db->createCommand("\n select count(*)\n from x2_actions\n where {$assignedToCondition} and (type='' or type is null)\n ")->queryScalar($params); $incomplete = Yii::app()->db->createCommand("\n select count(*)\n from x2_actions\n where {$assignedToCondition} and (type='' or type is null) and complete='No'\n ")->queryScalar($params); $overdue = Actions::model()->countByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => 'No'), 'dueDate < ' . time() . ' AND (type="" OR type IS NULL)'); $complete = Actions::model()->countByAttributes(array('completedBy' => Yii::app()->user->getName(), 'complete' => 'Yes'), 'type="" OR type IS NULL'); $this->render('actionMenu', array('total' => $total, 'unfinished' => $incomplete, 'overdue' => $overdue, 'complete' => $complete)); }
/** * @return void */ protected function __construct() { $this->oHttp = \MailSo\Base\Http::NewInstance(); $this->oActions = Actions::NewInstance(); $this->oActions->SetHttp($this->oHttp); $this->oTwilio = $this->oActions->GetTwilio(); \CApi::Plugin()->SetActions($this->oActions); // \MailSo\Config::$FixIconvByMbstring = false; \MailSo\Config::$SystemLogger = \CApi::MailSoLogger(); }
/** * @return void */ protected function __construct() { $this->oHttp = \MailSo\Base\Http::NewInstance(); $this->oActions = Actions::NewInstance(); $this->oActions->SetHttp($this->oHttp); $this->oTwilio = $this->oActions->GetTwilio(); \CApi::Plugin()->SetActions($this->oActions); // \MailSo\Config::$FixIconvByMbstring = false; \MailSo\Config::$SystemLogger = \CApi::MailSoLogger(); \MailSo\Config::$PreferStartTlsIfAutoDetect = !!\CApi::GetConf('labs.prefer-starttls', true); }
public function execute(&$params) { $action = new Actions(); $action->associationType = lcfirst(get_class($params['model'])); $action->associationId = $params['model']->id; $action->subject = $this->parseOption('subject', $params); $action->actionDescription = $this->parseOption('description', $params); if ($params['model']->hasAttribute('assignedTo')) { $action->assignedTo = $params['model']->assignedTo; } if ($params['model']->hasAttribute('priority')) { $action->priority = $params['model']->priority; } if ($params['model']->hasAttribute('visibility')) { $action->visibility = $params['model']->visibility; } if ($action->save()) { return array(true, Yii::t('studio', "View created action: ") . $action->getLink()); } else { return array(false, array_shift($action->getErrors())); } }
public static function executePostCommit() { $payload = json_decode($_REQUEST['payload'], true); $rawPost = file_get_contents('php://input'); $secret = trim(file_get_contents($_SERVER['ROOT_DIR'] . '/data/secret/github-secret')); Actions::returnErrorIf(!isset($_SERVER['HTTP_X_HUB_SIGNATURE']), "HTTP header 'X-Hub-Signature' is missing."); list($algo, $hash) = explode('=', $_SERVER['HTTP_X_HUB_SIGNATURE'], 2) + array('', ''); Actions::returnErrorIf(!in_array($algo, hash_algos(), TRUE), 'Invalid hash algorithm "' . $algo . '"'); Actions::returnErrorIf($hash !== hash_hmac($algo, $rawPost, $secret), 'Hash does not match. "' . $secret . '"' . ' algo: ' . $algo . '$'); if ($payload['ref'] === 'refs/heads/master') { $ret = shell_exec('sudo -u lbry ' . $_SERVER['ROOT_DIR'] . '/update.sh 2>&1'); echo "Successful post commit (aka the script executed, so maybe it is successful):\n"; echo $ret; } return [null, []]; }
public function run() { $total = Actions::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'type' => null)); $total = count($total); $temp = Actions::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => 'No', 'type' => null)); $unfinished = count($temp); $overdue = 0; foreach ($temp as $action) { if ($action->dueDate < time()) { $overdue++; } } $complete = Actions::model()->findAllByAttributes(array('completedBy' => Yii::app()->user->getName(), 'complete' => 'Yes', 'type' => null)); $complete = count($complete); $this->render('actionMenu', array('total' => $total, 'unfinished' => $unfinished, 'overdue' => $overdue, 'complete' => $complete)); }
public function assertActionCreated($type, $message = null) { $action = Actions::model()->findBySql("SELECT * FROM x2_actions WHERE type='{$type}' ORDER BY createDate DESC,id DESC LIMIT 1"); $this->assertTrue((bool) $action, "Failed asserting that an action was created. {$type}"); $associatedModel = X2Model::getAssociationModel($action->associationType, $action->associationId); // Test that the models are identical: $this->eml->targetModel->refresh(); foreach (array('myModelName', 'id', 'name', 'lastUpdated', 'createDate', 'assignedTo', 'status') as $property) { if ($this->eml->targetModel->hasProperty($property) && $associatedModel->hasProperty($property)) { $this->assertEquals($this->eml->targetModel->{$property}, $associatedModel->{$property}, "Failed asserting that an action's associated model record was the same, property: {$property}. {$message}"); } } // Assert that the username fields are set properly: foreach (array('assignedTo', 'completedBy') as $attr) { $this->assertEquals('testuser', $action->assignedTo, "Failed asserting that {$attr} was set properly on the action record. {$message}"); } }
public function init() { # these option settings are the wordpress default settings - you can # freely change or add anything that a normal CPT would have as an option $options = array('description' => __('Song'), 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'query_var' => true, 'menu_icon' => 'dashicons-book-alt', 'menu_position' => 47, 'capability_type' => 'post', 'hierarchical' => true, 'supports' => array('title', 'thumbnail'), 'taxonomies' => array('category', 'post_tag'), 'has_archive' => 'all/songs'); # these are the "labels" option when declaring a custom post type, # broken out here so that it's not a mess $labels = array('name' => __('Song', 'bonestheme'), 'singular_name' => __('Song', 'bonestheme'), 'all_items' => __('Manage Song ', 'bonestheme'), 'add_new' => __('Add New', 'bonestheme'), 'add_new_item' => __('Add New Song', 'bonestheme'), 'edit' => __('Edit', 'bonestheme'), 'edit_item' => __('Edit Song', 'bonestheme'), 'new_item' => __('New Song', 'bonestheme'), 'view_item' => __('View Song', 'bonestheme'), 'search_items' => __('Search Song', 'bonestheme'), 'not_found' => __("No Song found.", 'bonestheme'), 'not_found_in_trash' => __('Nothing found in Trash', 'bonestheme'), 'parent_item_colon' => ''); # the post type will initialize automatically when both of these # are set $this->labels($labels)->options($options); # Add categories to this post type Actions::on('init', function () { register_taxonomy_for_object_type('category', 'song'); }); # initialize the static custom fields for this post type $this->initializeFields(); $this->registerFilters(); return $this; }
/** * @return void */ private function __construct() { $this->oHttp = \MailSo\Base\Http::SingletonInstance(); $this->oActions = Actions::NewInstance(); \set_error_handler(array(&$this, 'LogPhpErrorHandler')); $this->oServiceActions = new \RainLoop\ServiceActions($this->oHttp, $this->oActions); if ($this->oActions->Config()->Get('debug', 'enable', false)) { \error_reporting(E_ALL); \ini_set('display_errors', 1); } if ($this->oActions->Config()->Get('labs', 'disable_iconv_if_mbstring_supported', false) && \class_exists('MailSo\\Capa') && \MailSo\Base\Utils::IsMbStringSupported()) { \MailSo\Config::$ICONV = false; } $sServer = \trim($this->oActions->Config()->Get('security', 'custom_server_signature', '')); if (0 < \strlen($sServer)) { @\header('Server: ' . $sServer, true); } if ($this->oActions->Config()->Get('labs', 'force_https', false) && !$this->oHttp->IsSecure()) { @\header('Location: https://' . $this->oHttp->GetHost(false, false) . $this->oHttp->GetUrl(), true); exit; } }
public static function getInstance($path) { global $plugin; $plugin = $path; if (!self::$obj instanceof self) { self::$obj = new self(); $dom = new DOMDocument(); $dom->load(dirname(__FILE__) . "/{$path}/actions.xml"); if (@$dom->validate()) { $packages = $dom->getElementsByTagName("package"); foreach ($packages as $package) { $actions = $package->getElementsByTagName('action'); $action_tem = array(); foreach ($actions as $action) { $action_tem['file'] = $action->getAttributeNode('file')->value; unset($action_tem['class']); if ($action->hasAttribute('class')) { $action_tem['class'] = $action->getAttributeNode('class')->value; } $action_tem['method'] = $action->getAttributeNode('method')->value; $returns = $action->getElementsByTagName('return'); $return_tem = array(); foreach ($returns as $return) { $return_tem[$return->getAttributeNode('name')->value] = $return->nodeValue; } $action_tem['returns'] = $return_tem; self::$action_info[$package->getAttributeNode('name')->value . '_' . $action->getAttributeNode('name')->value] = $action_tem; } // var_dump( self::$action_info); } } else { echo "此XML文件不符合规范!"; exit; } } return self::$obj; }
<?php get_header(); $sendit = new Actions(); $sendit->ConfirmSubscriber(); get_footer();
/** * Runs when a model is deleted. * Clears any entries in <tt>x2_phone_numbers</tt>. * Fires onAfterDelete event. */ public function afterDelete() { // Clear out old tags: $class = get_class($this); Tags::model()->deleteAllByAttributes(array('type' => $class, 'itemId' => $this->id)); // Clear out old phone numbers X2Model::model('PhoneNumber')->deleteAllByAttributes(array('modelId' => $this->id, 'modelType' => $class)); RecordAliases::model()->deleteAllByAttributes(array('recordId' => $this->id, 'recordType' => $class)); // Change all references to this record so that they retain the name but // exclude the ID: if ($this->hasAttribute('nameId') && $this->hasAttribute('name')) { $this->_oldAttributes = $this->getAttributes(); $this->nameId = $this->name; $this->updateNameIdRefs(); } // clear out associated actions Actions::model()->deleteAllByAttributes(array('associationType' => strtolower(self::getAssociationType(get_class($this))), 'associationId' => $this->id)); if ($this->hasEventHandler('onAfterDelete')) { $this->onAfterDelete(new CEvent($this)); } }
/** * Retrieve calendar events for a given user happening between two specified * dates. * @param string|integer $calendarUser Username or group ID whose calendar * events are to be loaded and returned * @param type $start Beginning time range * @param type $end End time range * @param mixed $includePublic Set to 1 or boolean true to include all * calendar events * @return array An array of action records */ public function calendarActions($calendarUser, $start, $end) { $filter = explode(',', $this->currentUser->calendarFilter); // action types user doesn't want filtered $staticAction = Actions::model(); // View permissions for the viewing user $criteria = $staticAction->getAccessCriteria(); // Assignment condition: all events for the user whose calendar is being viewed: $criteria->addCondition('`assignedTo` REGEXP BINARY :unameRegex'); $permissionsBehavior = Yii::app()->params->modelPermissions; $criteria->params[':unameRegex'] = $permissionsBehavior::getUserNameRegex($calendarUser); // Action type filters: $criteria->addCondition(self::constructFilterClause($filter)); $criteria->addCondition("`type` IS NULL OR `type`='' OR `type`!='quotes'"); $criteria->addCondition('(`dueDate` >= :start1 AND `dueDate` <= :end1) ' . 'OR (`completeDate` >= :start2 AND `completeDate` <= :end2)'); $criteria->params = array_merge($criteria->params, array(':start1' => $start, ':start2' => $start, ':end1' => $end, ':end2' => $end)); return Actions::model()->findAllWithoutActionText($criteria); }
</div>--> <div class="icon <?php echo $type; ?> "> <div class="stacked-icon"></div> </div> <div class="header"> <?php if (empty($data->type) || $data->type == 'weblead') { echo "<span style='color:grey;cursor:pointer' class='action-frame-link' data-action-id='{$data->id}'>"; if ($data->complete == 'Yes') { echo Yii::t('actions', 'Completed:') . " </span>" . Formatter::formatCompleteDate($data->completeDate); } else { if (!empty($data->dueDate)) { echo Yii::t('actions', 'Due:') . " </span>" . Actions::parseStatus($data->dueDate) . '</b>'; } elseif (!empty($data->createDate)) { echo Yii::t('actions', 'Created:') . " </span>" . Formatter::formatLongDateTime($data->createDate) . '</b>'; } else { echo " "; } } } elseif ($data->type == 'workflow') { // $actionData = explode(':',$data->actionDescription); echo Yii::t('workflow', 'Process:') . '<b> ' . $data->workflow->name . '/' . $data->workflowStage->name . '</b> '; } elseif ($data->type == 'event') { echo '<b>' . CHtml::link(Yii::t('calendar', 'Event') . ': ', '#', array('class' => 'action-frame-link', 'data-action-id' => $data->id)); if ($data->allDay) { echo Formatter::formatLongDate($data->dueDate); if ($data->completeDate) { echo ' - ' . Formatter::formatLongDate($data->completeDate);
public static function getPriorityLabels() { if (!isset(self::$_priorityLabels)) { self::$_priorityLabels = array(1 => Yii::t('actions', 'Low'), 2 => Yii::t('actions', 'Medium'), 3 => Yii::t('actions', 'High')); } return self::$_priorityLabels; }
/** * Looks up notification criteria in x2_criteria relevant to this model * and field and performs the specified operation. * Soon to be eliminated in wake of x2flow automation system. * * @param string $fieldName the name of the current field * @param string $old the old value * @param string $new the new value */ public function checkNotificationCriteria($fieldName, $old, $new) { $model = $this->getOwner(); $modelClass = get_class($model); $allCriteria = Criteria::model()->findAllByAttributes(array('modelType' => $modelClass, 'modelField' => $fieldName)); foreach ($allCriteria as $criteria) { if ($criteria->comparisonOperator == "=" && $new == $criteria->modelValue || $criteria->comparisonOperator == ">" && $new >= $criteria->modelValue || $criteria->comparisonOperator == "<" && $new <= $criteria->modelValue || $criteria->comparisonOperator == "change" && $new != $old) { $users = preg_split('/[\\s,]+/', $criteria->users, null, PREG_SPLIT_NO_EMPTY); if ($criteria->type == 'notification') { foreach ($users as $user) { $event = new Events(); $event->user = $user; $event->associationType = 'Notification'; $event->type = 'notif'; $notif = new Notification(); $notif->type = 'change'; $notif->fieldName = $fieldName; $notif->modelType = get_class($model); $notif->modelId = $model->id; if ($criteria->comparisonOperator == 'change') { $notif->comparison = 'change'; // if the criteria is just 'changed' $notif->value = $new; // record the new value } else { $notif->comparison = $criteria->comparisonOperator; // otherwise record the operator type $notif->value = mb_substr($criteria->modelValue, 0, 250, 'UTF-8'); // and the comparison value } $notif->user = $user; $notif->createdBy = $this->editingUsername; $notif->createDate = time(); if ($notif->save()) { $event->associationId = $notif->id; $event->save(); } } } elseif ($criteria->type == 'action') { foreach ($users as $user) { $action = new Actions(); $action->assignedTo = $user; if ($criteria->comparisonOperator == "=") { $action->actionDescription = "A record of type " . $modelClass . " has been modified to meet {$criteria->modelField} {$criteria->comparisonOperator} {$criteria->modelValue}" . " by " . $this->editingUsername; } else { if ($criteria->comparisonOperator == ">") { $action->actionDescription = "A record of type " . $modelClass . " has been modified to meet {$criteria->modelField} {$criteria->comparisonOperator} {$criteria->modelValue}" . " by " . $this->editingUsername; } else { if ($criteria->comparisonOperator == "<") { $action->actionDescription = "A record of type " . $modelClass . " has been modified to meet {$criteria->modelField} {$criteria->comparisonOperator} {$criteria->modelValue}" . " by " . $this->editingUsername; } else { if ($criteria->comparisonOperator == "change") { $action->actionDescription = "A record of type " . $modelClass . " has had its {$criteria->modelField} field changed from " . $old . ' to ' . $new . ' by ' . $this->editingUsername; } } } } $action->dueDate = mktime('23', '59', '59'); $action->createDate = time(); $action->lastUpdated = time(); $action->updatedBy = 'admin'; $action->visibility = 1; $action->associationType = lcfirst($modelClass); $action->associationId = $model->id; $action->associationName = $model->name; $action->save(); } } elseif ($criteria->type == 'assignment') { $model->assignedTo = $criteria->users; if ($model->save()) { $event = new Events(); $event->type = 'notif'; $event->user = $model->assignedTo; $event->associationType = 'Notification'; $notif = new Notification(); $notif->user = $model->assignedTo; $notif->createDate = time(); $notif->type = 'assignment'; $notif->modelType = $modelClass; $notif->modelId = $model->id; if ($notif->save()) { $event->associationId = $notif->id; if ($this->createEvent) { $event->save(); } } } } } } }
public function testRecordEmailSent() { $contact = $this->contacts('testUser'); $campaign = $this->campaign('testUser'); $now = time(); CampaignMailingBehavior::recordEmailSent($campaign, $contact); $action = Actions::model()->findByAttributes(array('associationType' => 'contacts', 'associationId' => $contact->id, 'type' => 'email')); $this->assertTrue((bool) $action); $this->assertTrue(abs($action->completeDate - $now) <= 1); }