/** * Return full rendered changelog * @param Changelog $changelog * @return string */ public function render(Changelog $changelog) { $this->_output = ''; $this->_version = $changelog->getVersion(); $rawData = $changelog->getRawData(); foreach ($rawData as $tag => $data) { $this->_output .= $this->_render($data['groups'], $data['time'], $tag); } return $this->_output; }
/** * Delete all changelog entries from the database. */ public function actionClearChangelog() { Changelog::model()->deleteAll(); $this->redirect('viewChangelog'); }
$this->import('BackendUser', 'User'); parent::__construct(); $this->User->authenticate(); } /** * Run the controller */ public function run() { $strBuffer = file_get_contents(TL_ROOT . '/system/docs/CHANGELOG.md'); $strBuffer = str_replace("\r", '', $strBuffer); // see #4190 $strBuffer = preg_replace(array('/#([0-9]+)/', '/(---+\\n)(?!\\n)/', '/([^\\n]+)\\n===+\\n/', '/([^\\n]+)\\n---+\\n/', '/\\n### ([^\\n]+)\\n/', '/ _(?!_)/', '/_ /', '/===+\\n/'), array('<a href="https://github.com/contao/core/issues/$1" target="_blank">#$1</a>', "\$1\n", '<h2>$1</h2>', "<h3>\$1</h3>\n", "<h4>\$1</h4>\n", ' <em>', '</em> ', ''), $strBuffer); $strBuffer = str_replace(array("\n\n```\n", "\n```\n\n", ' `', '` ', '(`', '`)', "\n`", "`\n", '`.', '`,'), array("\n\n<pre>", "</pre>\n\n", ' <code>', '</code> ', '(<code>', '</code>)', "\n<code>", "</code>\n", '</code>.', '</code>,'), trim($strBuffer)); $this->Template = new BackendTemplate('be_changelog'); // Template variables $this->Template->content = $strBuffer; $this->Template->theme = $this->getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['changelog']); $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet']; $GLOBALS['TL_CONFIG']['debugMode'] = false; $this->Template->output(); } } /** * Instantiate the controller */ $objChangelog = new Changelog(); $objChangelog->run();
/** * Sets the lastUpdated and updatedBy fields to reflect recent changes. * @param type $model The model to be updated * @return type $model The model with modified attributes */ protected function updateChangelog($model, $change) { $model->lastUpdated=time(); $model->updatedBy=Yii::app()->user->getName(); $changelog=new Changelog; $changelog->type=get_class($model); $changelog->itemId=$model->id; $changelog->changedBy=Yii::app()->user->getName(); $changelog->changed=$change; $changelog->timestamp=time(); $changelog->save(); return $model; }
/** * Writes field changes to the changelog. Calls {@link checkNotificationCriteria()} for each change * @param array $changes the changes array, calls {@link getChanges()} if not provided */ public function updateChangelog($changes = null) { $model = $this->getOwner(); if ($changes === null) { $changes = $this->getChanges(); } // $model->lastUpdated = time(); // $model->updatedBy = Yii::app()->user->getName(); // $model->save(); $type = get_class($model); // Handle special types $pluralize = array('Quote', 'Product'); if (in_array($type, $pluralize)) { $type .= "s"; } else { if ($type == 'Campaign') { $type = "Marketing"; } else { if ($type == 'bugreports') { $type = 'BugReports'; } } } $excludeFields = array('lastUpdated', 'createDate', 'lastActivity', 'updatedBy', 'trackingKey'); if (is_array($changes)) { foreach ($changes as $fieldName => $change) { if (!in_array($fieldName, $excludeFields)) { $changelog = new Changelog(); $changelog->type = $type; if (!isset($model->id)) { if ($model->save()) { } } $changelog->itemId = $model->id; if ($model->hasAttribute('name')) { $changelog->recordName = $model->name; } else { $changelog->recordName = $type; } $changelog->changedBy = $this->editingUsername; $changelog->fieldName = $fieldName; $changelog->oldValue = $change[0]; $changelog->newValue = $change[1]; $changelog->timestamp = time(); $changelog->save(); $this->checkNotificationCriteria($fieldName, $change[0], $change[1]); } } } // } elseif($changes == 'Create' || $changes == 'Edited') { // if($model instanceof Contacts) // $change = $model->backgroundInfo; // else if($model instanceof Actions) // $change = $model->actionDescription; // else if($model instanceof Docs) // $change = $model->text; // else // $change = $model->name; // } elseif($changes != '' && $changes != 'Completed') { // $pieces = explode("<br />", $change); // foreach($pieces as $piece) { // $newPieces = explode("TO:", $piece); // $forDeletion = $newPieces[0]; // if(isset($newPieces[1]) && preg_match('/<b>' . Yii::t('actions', 'color') . '<\/b>/', $piece) == false) { // $changes[] = $newPieces[1]; // } // } // } }
public static function updateWorkflowChangelog(&$action, $changeType, &$model) { $changelog = new Changelog(); // $type = $action->associationType=='opportunities'?"Opportunity":ucfirst($action->associationType); $changelog->type = get_class($model); $changelog->itemId = $action->associationId; // $record=X2Model::model(ucfirst($type))->findByPk($action->associationId); // if(isset($record) && $record->hasAttribute('name')){ // $changelog->recordName=$record->name; // }else{ // $changelog->recordName=$type; // }X2Flow::trigger('WorkflowStageCompleteTrigger',array('workflow'=>'model'=>$model)); $changelog->recordName = $model->name; $changelog->changedBy = Yii::app()->user->getName(); $changelog->timestamp = time(); $changelog->oldValue = ''; $workflowName = $action->workflow->name; // $workflowName = Yii::app()->db->createCommand()->select('name')->from('x2_workflows')->where('id=:id',array(':id'=>$action->workflowId))->queryScalar(); $stageName = Yii::app()->db->createCommand()->select('name')->from('x2_workflow_stages')->where('workflowId=:id AND stageNumber=:sn', array(':sn' => $action->stageNumber, ':id' => $action->workflowId))->queryScalar(); $event = new Events(); $event->associationType = 'Actions'; $event->associationId = $action->id; $event->user = Yii::app()->user->getName(); if ($changeType === 'start') { //$trigger = 'WorkflowStartStageTrigger'; $event->type = 'workflow_start'; $changelog->newValue = 'Workflow Stage Started: ' . $stageName; } elseif ($changeType === 'complete') { //$trigger = 'WorkflowCompleteStageTrigger'; $event->type = 'workflow_complete'; $changelog->newValue = 'Workflow Stage Completed: ' . $stageName; } elseif ($changeType === 'revert') { //$trigger = 'WorkflowRevertStageTrigger'; $event->type = 'workflow_revert'; $changelog->newValue = 'Workflow Stage Reverted: ' . $stageName; } else { return; } /*X2Flow::trigger($trigger,array( 'workflow'=>$action->workflow, 'model'=>$model, 'stageNumber'=>$action->stageNumber, 'stageName'=>$stageName, ));*/ $event->save(); $changelog->save(); }
protected function beforeSave() { if ($this->off_status == self::STATUS_ACCEPTED) { $statuses = [Offer::STATUS_ACCEPTED, Offer::STATUS_NOT_SUBMITTED, Offer::STATUS_REJECTED, Offer::STATUS_SUBMITTED]; $this->updateAll(['off_status' => Offer::STATUS_REJECTED], "off_deal = '" . $this->off_deal . "' AND off_status IN ('" . implode("','", $statuses) . "')"); } if (!$this->isNewRecord) { /** @var $oldRecord Offer */ $oldRecord = $this->findByPk($this->off_id); // retrieve old version of that record; foreach ($this->attributeLabels() as $eachAttr => $eachLabel) { if (!empty($this->{$eachAttr}) && $oldRecord->{$eachAttr} !== $this->{$eachAttr}) { $change = new Changelog(); $change->cha_session = session_id(); $change->cha_table = $this->tableName(); $change->cha_old = $oldRecord->{$eachAttr}; $change->cha_new = $this->{$eachAttr}; $change->cha_field = $eachAttr; $change->cha_row = $this->off_id; $change->cha_action = Changelog::ACTION_UPDATE; $change->save(); } } } $this->off_timestamp = date("Y-m-d H:i:s"); return parent::beforeSave(); }
private function updateWorkflowChangelog(&$action, $changeType) { // die(var_dump($action)); $changelog = new Changelog(); $changelog->type = ucfirst($action->associationType); $changelog->itemId = $action->associationId; $changelog->changedBy = Yii::app()->user->getName(); $changelog->timestamp = time(); $workflowName = Yii::app()->db->createCommand()->select('name')->from('x2_workflows')->where('id=:id', array(':id' => $action->workflowId))->queryScalar(); $stageName = Yii::app()->db->createCommand()->select('name')->from('x2_workflow_stages')->where('workflowId=:id AND stageNumber=:sn', array(':sn' => $action->stageNumber, ':id' => $action->workflowId))->queryScalar(); $stageText = Yii::t('workflow', '<b>Stage {n}: {stageName}</b> in <b>{workflowName}</b>', array('{n}' => $action->stageNumber, '{stageName}' => $stageName, '{workflowName}' => $workflowName)); if ($changeType == 'start') { $changelog->changed = Yii::t('workflow', '<u>STARTED</u> {stage}', array('{stage}' => $stageText)); } elseif ($changeType == 'complete') { $changelog->changed = Yii::t('workflow', '<u>COMPLETED</u> {stage}', array('{stage}' => $stageText)); } elseif ($changeType == 'revert') { $changelog->changed = Yii::t('workflow', '<u>REVERTED</u> {stage}', array('{stage}' => $stageText)); } else { return; } $changelog->save(); }
/** * Sets the lastUpdated and updatedBy fields to reflect recent changes. * @param type $model The model to be updated * @return type $model The model with modified attributes */ protected function updateChangelog($model, $change) { $model->lastUpdated = time(); $model->updatedBy = Yii::app()->user->getName(); $model->save(); $type = get_class($model); if (substr($type, -1) != "s") { $type = substr($type, 0, -5) . "s"; } $changelog = new Changelog(); $changelog->type = $type; if (!isset($model->id)) { if ($model->save()) { } } $changelog->itemId = $model->id; $changelog->changedBy = Yii::app()->user->getName(); $changelog->changed = $change; $changelog->timestamp = time(); if ($changelog->save()) { } $changes = array(); if ($change != 'Create' && $change != 'Completed' && $change != 'Edited') { if ($change != "") { $pieces = explode("<br />", $change); foreach ($pieces as $piece) { $newPieces = explode("TO:", $piece); $forDeletion = $newPieces[0]; if (isset($newPieces[1]) && preg_match('/<b>' . Yii::t('actions', 'color') . '<\\/b>/', $piece) == false) { $changes[] = $newPieces[1]; } preg_match_all('/(^|\\s|)#(\\w\\w+)/', $forDeletion, $deleteMatches); $deleteMatches = $deleteMatches[0]; foreach ($deleteMatches as $match) { $oldTag = Tags::model()->findByAttributes(array('tag' => substr($match, 1), 'type' => $type, 'itemId' => $model->id)); if (isset($oldTag)) { $oldTag->delete(); } } } } } else { if ($change == 'Create' || $change == 'Edited') { if ($model instanceof Contacts) { $change = $model->backgroundInfo; } else { if ($model instanceof Actions) { $change = $model->actionDescription; } else { if ($model instanceof Docs) { $change = $model->text; } else { $change = $model->name; } } } } } foreach ($changes as $change) { preg_match_all('/(^|\\s|)#(\\w\\w+)/', $change, $matches); $matches = $matches[0]; foreach ($matches as $match) { $tag = new Tags(); $tag->type = $type; $tag->taggedBy = Yii::app()->user->getName(); $tag->type = $type; //cut out leading whitespace $tag->tag = trim($match); if ($model instanceof Contacts) { $tag->itemName = $model->firstName . " " . $model->lastName; } else { if ($model instanceof Actions) { $tag->itemName = $model->actionDescription; } else { if ($model instanceof Docs) { $tag->itemName = $model->title; } else { $tag->itemName = $model->name; } } } if (!isset($model->id)) { $model->save(); } $tag->itemId = $model->id; $tag->timestamp = time(); //save tags including # sign if ($tag->save()) { } } } return $model; }
protected function beforeSave() { if ($this->isNewRecord) { $this->not_date = date("Y-m-d H:i:s"); $this->not_user = Yii::app()->user->getId(); } else { if ($this->not_blurb) { /** @var $oldRecord Note */ $oldRecord = $this->findByPk($this->not_id); // retrieve old version of that record; if ($oldRecord->not_blurb !== $this->not_blurb) { $change = new Changelog(); $change->cha_session = session_id(); $change->cha_table = $this->tableName(); $change->cha_old = $oldRecord->not_blurb; $change->cha_new = $this->not_blurb; $change->cha_field = 'not_blurb'; $change->cha_row = $this->not_id; $change->cha_action = Changelog::ACTION_UPDATE; $change->save(); } } } $this->not_edited = date("Y-m-d H:i:s"); return parent::beforeSave(); }
protected function beforeSave() { if (!$this->isNewRecord) { /** @var $oldRecord Deal */ $oldRecord = $this->findByPk($this->dea_id); // retrieve old version of that record; foreach ($this->attributes as $eachAttr => $eachAttrVal) { if ($oldRecord->{$eachAttr} !== $this->{$eachAttr}) { $change = new Changelog(); $change->cha_table = $this->tableName(); $change->cha_old = $oldRecord->{$eachAttr}; $change->cha_new = $this->{$eachAttr}; $change->cha_field = $eachAttr; $change->cha_row = $this->dea_id; $change->cha_session = session_id(); $change->cha_action = Changelog::ACTION_UPDATE; $change->save(); } } if ($oldRecord->dea_status !== $this->dea_status) { $stateOfTrade = new StateOfTrade(); $stateOfTrade->sot_deal = $this->dea_id; $stateOfTrade->sot_status = $this->dea_status; $stateOfTrade->save(false); if ($this->dea_status == self::STATUS_AVAILABLE) { $this->launch(); } } } else { $this->dea_created = date('Y-m-d H:i:s'); $this->createdBy = Yii::app()->user->id; } $this->followUpDue = Date::parseDate($this->followUpDue); $this->valuationDate = Date::parseDate($this->valuationDate); $this->dea_exchdate = Date::parseDate($this->dea_exchdate); $this->dea_compdate = Date::parseDate($this->dea_compdate); $this->modifiedBy = Yii::app()->user->id; $this->dea_marketprice = (double) preg_replace('/[^0-9.]/i', '', $this->dea_marketprice); return parent::beforeSave(); }
/** * @param $instructionId * @param $columnName * @throws CHttpException * @return bool */ public function actionShowChangeLogs($instructionId, $columnName) { $this->layout = "//layouts/new/popup"; if (!$instructionId) { throw new CHttpException(404, 'Instruction id must be passed'); } $historyCriteria = new CDbCriteria(); $historyCriteria->compare('cha_row', $instructionId, false, 'AND', false); $historyCriteria->compare('cha_field', $columnName, false, 'AND', false); $historyCriteria->order = 'cha_datetime DESC'; $dealChangeLog = Changelog::model()->findAll($historyCriteria); $this->render('_changeLogs', ['dealChangeLog' => $dealChangeLog]); }