public function actionEdit() { $id = Yii::app()->request->getParam('id'); // Current wall type we are in (Dashboard, Space, User) // Used to properly render the result wall item. $wallType = Yii::app()->request->getParam('wallType'); $edited = false; $model = Post::model()->findByPk($id); if ($model->content->canWrite()) { if (isset($_POST['Post'])) { $_POST['Post'] = Yii::app()->input->stripClean($_POST['Post']); $model->attributes = $_POST['Post']; if ($model->validate()) { $model->save(); // Reload record to get populated updated_at field $model = Post::model()->findByPk($id); // Set current wall type Wall::$currentType = $wallType; // Return the new post $output = $this->widget('application.modules_core.post.widgets.PostWidget', array('post' => $model, 'justEdited' => true), true); Yii::app()->clientScript->render($output); echo $output; return; } } $this->renderPartial('edit', array('post' => $model, 'edited' => $edited, 'wallType' => $wallType), false, true); } else { throw new CHttpException(403, Yii::t('PostModule.controllers_PostController', 'Access denied!')); } }
/** * Runs the activity widget */ public function run() { // Save Wall Type Wall::$currentType = $this->type; $javascriptVariablePass = "******" . Yii::app()->createUrl('//wall/wall/streamActivity', array('type' => $this->type, 'guid' => $this->guid, 'limit' => 10, 'from' => 'lastEntryId')) . "';\n"; $javascriptVariablePass .= "var activityStartUrl = '" . Yii::app()->createUrl('//wall/wall/streamActivity', array('type' => $this->type, 'guid' => $this->guid, 'limit' => 10)) . "';\n"; $javascriptVariablePass .= "var activityPermaLinkUrl = '" . Yii::app()->createUrl('//wall/perma/wallEntry') . "';\n"; Yii::app()->clientScript->registerScript('activityUrls', $javascriptVariablePass, CClientScript::POS_BEGIN); $this->render('activityStream', array()); }
/** * Creates the Wall Widget */ public function run() { // Save Wall Type Wall::$currentType = $this->type; $guid = null; if ($this->contentContainer != "") { $guid = $this->contentContainer->guid; } // Set some Urls for this wall $reloadUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $this->wallObjectStreamLimit, 'from' => 'lastEntryId', 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $startUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $this->wallObjectStreamLimit, 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $singleEntryUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => 1, 'from' => 'fromEntryId')); // Render It $this->render('stream', array('type' => $this->type, 'reloadUrl' => $reloadUrl, 'startUrl' => $startUrl, 'singleEntryUrl' => $singleEntryUrl)); }
/** * Creates the Wall Widget */ public function run() { // Should be at least 4, because its possible to stick at maximum 3 object // Otherwise sticky system may break the wall $wallObjectStreamLimit = 4; // Save Wall Type Wall::$currentType = $this->type; $guid = null; if ($this->contentContainer != "") { $guid = $this->contentContainer->guid; } // Set some Urls for this wall $reloadUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $wallObjectStreamLimit, 'from' => 'lastEntryId', 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $startUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $wallObjectStreamLimit, 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $singleEntryUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => 1, 'from' => 'fromEntryId')); // Render It $this->render('stream', array('type' => $this->type, 'reloadUrl' => $reloadUrl, 'startUrl' => $startUrl, 'singleEntryUrl' => $singleEntryUrl)); }
/** * Creates the Wall Widget */ public function run() { // Save Wall Type Wall::$currentType = $this->type; $guid = null; if ($this->contentContainer != "") { $guid = $this->contentContainer->guid; } // Set some Urls for this wall $reloadUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $this->wallObjectStreamLimit, 'from' => 'lastEntryId', 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $startUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => $this->wallObjectStreamLimit, 'filters' => 'filter_placeholder', 'sort' => 'sort_placeholder')); $singleEntryUrl = Yii::app()->createUrl($this->streamAction, array('type' => $this->type, 'guid' => $guid, 'limit' => 1, 'from' => 'fromEntryId')); $view = 'stream_deprecated'; /** * For backward compatiblity use modules 'stream' view */ if (get_class($this) != 'WallStreamWidget') { $view = 'stream'; } // Render It $this->render($view, array('type' => $this->type, 'reloadUrl' => $reloadUrl, 'startUrl' => $startUrl, 'singleEntryUrl' => $singleEntryUrl)); }
/** * Execute the Stream Action and returns a JSON output. */ public function run() { $this->init(); $this->prepareSQL(); $this->setupFilterSQL(); Yii::beginProfile('runStreamAction'); $stickedFirstOrder = ""; // Show sticked items? if (($this->type == Wall::TYPE_SPACE || $this->type == Wall::TYPE_USER) && $this->wallEntryLimit != 1) { if ($this->wallEntryFrom == "") { $stickedFirstOrder = "content.sticked DESC,"; } else { $this->sqlWhere .= " AND (content.sticked != 1 OR content.sticked is NULL)"; } } //$order = "ORDER BY ".$stickedFirstOrder."wall_entry.created_at DESC"; $order = "ORDER BY " . $stickedFirstOrder . "wall_entry.id DESC"; if ($this->sorting == self::SORT_UPDATED_AT) { $order = "ORDER BY " . $stickedFirstOrder . "wall_entry.updated_at DESC"; } $sql = "SELECT wall_entry.*\n\t\t\tFROM wall_entry\n LEFT JOIN content ON wall_entry.content_id = content.id\n LEFT JOIN user creator ON creator.id = content.created_by\n\t\t\t{$this->sqlJoin}\n\t\t\tWHERE creator.status = 1\n\t\t\t{$this->sqlWhere}\n\t\t\t{$this->sqlGroupBy}\n {$order}\n\t\t\tLIMIT {$this->wallEntryLimit}\n\t\t"; // Execute SQL $entries = WallEntry::model()->with('content')->findAllBySql($sql, $this->sqlParams); // Save Wall Type Wall::$currentType = $this->type; $output = ""; $lastEntryId = ""; $generatedWallEntryIds = array(); foreach ($entries as $entry) { $underlyingObject = $entry->content->getUnderlyingObject(); $user = $underlyingObject->content->user; $output .= Yii::app()->getController()->renderPartial('application.modules_core.wall.views.wallEntry', array('entry' => $entry, 'user' => $user, 'mode' => $this->mode, 'object' => $underlyingObject, 'content' => $underlyingObject->getWallOut()), true); $generatedWallEntryIds[] = $entry->id; $lastEntryId = $entry->id; } // Fire JQuery Time AGO Yii::app()->clientScript->registerScript('timeago', '$(".time").timeago();'); $pageOut = ""; Yii::app()->clientScript->renderHead($pageOut); Yii::app()->clientScript->renderBodyBegin($pageOut); $pageOut .= $output; Yii::app()->clientScript->renderBodyEnd($pageOut); $json = array(); $json['output'] = $pageOut; $json['lastEntryId'] = $lastEntryId; $json['counter'] = count($entries); $json['entryIds'] = $generatedWallEntryIds; Yii::endProfile('runStreamAction'); echo CJSON::encode($json); Yii::app()->end(); }