示例#1
0
 /**
  * Provides functionality to view a given profile
  * @param  int 	  $id          The ID belonging to the user
  * @param  string $displayName The user's display name. This isn't super necessary, it just is better for SEO
  */
 public function actionIndex($id = NULL, $displayName = NULL)
 {
     // If an ID isn't provided, throw an error
     if ($id === NULL) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     // For SEO, if the display name isn't in the url, reroute it
     if ($id !== NULL && $displayName === NULL) {
         $model = Users::model()->findByPk($id);
         if ($model === NULL || $model->status == 0) {
             throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
         } else {
             $this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\\da-z]/i', '', $model->displayName));
         }
     }
     $model = Users::model()->findByPk($id);
     // Don't allow null signings or invalidated users to pollute our site
     if ($model->status == 0) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     $this->pageTitle = $model->displayName . ' | ' . Cii::getConfig('name', Yii::app()->name);
     $postsCriteria = Content::model()->getBaseCriteria()->addCondition('type_id=2')->addCondition('password=""')->addCondition('author_id=:id');
     $postsCriteria->params = array(':id' => $id);
     $contentCount = Content::model()->count($postsCriteria);
     $this->render('index', array('model' => $model, 'contentCount' => $contentCount));
 }
示例#2
0
 /**
  * Initiates the password reset process on behalf of the user
  * Generates a unique hash and an expiration time that the hash is valid up until (defaults to 15 minutes)
  * This key will internally expire (but not be expunged) after that time
  */
 public function initPasswordResetProcess()
 {
     if (!$this->validate()) {
         return false;
     }
     $hash = Cii::generateSafeHash();
     $expires = strtotime("+15 minutes");
     $meta = UserMetadata::model()->findByAttributes(array('user_id' => $this->_user->id, 'key' => 'passwordResetCode'));
     if ($meta === NULL) {
         $meta = new UserMetadata();
     }
     $meta->user_id = $this->_user->id;
     $meta->key = 'passwordResetCode';
     $meta->value = $hash;
     $meta->save();
     $meta = UserMetadata::model()->findByAttributes(array('user_id' => $this->_user->id, 'key' => 'passwordResetExpires'));
     if ($meta === NULL) {
         $meta = new UserMetadata();
     }
     $meta->user_id = $this->_user->id;
     $meta->key = 'passwordResetExpires';
     $meta->value = $expires;
     $meta->save();
     $emailSettings = new EmailSettings();
     $emailSettings->send($this->_user, Yii::t('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
     // Set success flash
     Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array('{{email}}' => $this->email)));
     return true;
 }
示例#3
0
 /**
  * Retrieves all of the themes from webroot.themes and returns them in an array group by type, each containing
  * the contents of theme.json.
  *
  * The themes are then cached for easy retrieval later. (I really hate unecessary DiskIO if something isn't changing...)
  *
  * @return array
  */
 public function getThemes()
 {
     $themes = Yii::app()->cache->get('settings_themes');
     if ($themes == false) {
         $themes = array();
         $currentTheme = Cii::getConfig('theme');
         $themePath = Yii::getPathOfAlias('base.themes') . DS;
         $directories = glob($themePath . "*", GLOB_ONLYDIR);
         // Pushes the current theme onto the top of the list
         foreach ($directories as $k => $dir) {
             if ($dir == Yii::getPathOfAlias('base.themes') . DS . $currentTheme) {
                 unset($directories[$k]);
                 break;
             }
         }
         array_unshift($directories, $themePath . $currentTheme);
         foreach ($directories as $dir) {
             $json = CJSON::decode(file_get_contents($dir . DIRECTORY_SEPARATOR . 'composer.json'));
             $name = $json['name'];
             $key = str_replace('ciims-themes/', '', $name);
             $themes[$key] = array('path' => $dir, 'name' => $name, 'hidden' => isset($json['hidden']) ? $json['hidden'] : false);
         }
         Yii::app()->cache->set('settings_themes', $themes);
         return $themes;
     }
     return $themes;
 }
 /**
  * Displays a listing of all blog posts
  */
 public function actionList()
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Categories', 'Categories'))));
     $this->setLayout('main');
     $this->breadcrumbs = array(Yii::t('ciims.controllers.Categories', 'All Categories'));
     $criteria = new CDbCriteria();
     $criteria->addCondition('id != 1');
     $categories = Categories::model()->findAll($criteria);
     $this->render('list', array('categories' => $categories));
 }
示例#5
0
 /**
  * Creates a new comment
  * TODO: Figure out how to fix the email issues
  * @param  int  $id   The Comment id
  * @return array
  */
 private function createComment()
 {
     $model = new Comments();
     $model->attributes = $_POST;
     $model->approved = Cii::getConfig('autoApproveComments', 0);
     if ($model->save()) {
         return $model->getApiAttributes();
     }
     return $this->returnError(400, NULL, $model->getErrors());
 }
示例#6
0
 /**
  * Generic method for sending an email. Instead of having to call a bunch of code all over over the place
  * This method can be called which should be able to handle almost anything.
  *
  * By calling this method, the SMTP details will automatically be setup as well the notify email and user
  *
  * @param  Users   $user          The User we are sending the email to
  * @param  string  $subject       The email Subject
  * @param  string  $viewFile      The view file we want to render. Generally this should be in the form //email/<file>
  *                                And should correspond to a viewfile in /themes/<theme>/views/email/<file>
  * @param  array   $content       The content to pass to renderPartial()
  * @param  boolean $return        Whether the output should be returned. The default is TRUE since this output will be passed to MsgHTML
  * @param  boolean $processOutput Whether the output should be processed. The default is TRUE since this output will be passed to MsgHTML
  * @return boolean                Whether or not the email sent sucessfully
  */
 public function send($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug = false)
 {
     $mail = new PHPMailer($debug);
     $mail->IsSMTP();
     $mail->SMTPAuth = false;
     $smtpHost = Cii::getConfig('SMTPHost', NULL);
     $smtpPort = Cii::getConfig('SMTPPort', NULL);
     $smtpUser = Cii::getConfig('SMTPUser', NULL);
     $smtpPass = Cii::getConfig('SMTPPass', NULL);
     $useTLS = Cii::getConfig('useTLS', 0);
     $useSSL = Cii::getConfig('useSSL', 0);
     $notifyUser = new stdClass();
     if (isset($content['origin_from'])) {
         $notifyUser->email = $content['origin_from']['email'];
         $notifyUser->username = $content['origin_from']['name'];
     } else {
         $notifyUser->email = Cii::getConfig('notifyEmail', NULL);
         $notifyUser->username = Cii::getConfig('notifyName', NULL);
     }
     if ($smtpHost !== NULL && $smtpHost !== "") {
         $mail->Host = $smtpHost;
     }
     if ($smtpPort !== NULL && $smtpPort !== "") {
         $mail->Port = $smtpPort;
     }
     if ($smtpUser !== NULL && $smtpUser !== "") {
         $mail->Username = $smtpUser;
         $mail->SMTPAuth = true;
     }
     if ($useTLS == 1) {
         $mail->SMTPSecure = 'tls';
     }
     if ($useSSL == 1) {
         $mail->SMTPSecure = 'ssl';
     }
     if (!empty($smtpPass)) {
         $mail->Password = Cii::decrypt($smtpPass);
         $mail->SMTPAuth = true;
     }
     if ($notifyUser->email == NULL && $notifyUser->username == NULL) {
         $notifyUser = Users::model()->findByPk(1);
     }
     $mail->SetFrom($notifyUser->email, $notifyUser->username);
     $mail->Subject = $subject;
     $mail->MsgHTML($this->renderFile(Yii::getPathOfAlias($viewFile) . '.php', $content, $return, $processOutput));
     $mail->AddAddress($user->email, $user->username);
     try {
         return $mail->Send();
     } catch (phpmailerException $e) {
         return $debug ? $e->errorMessage() : false;
     } catch (Exception $e) {
         return $debug ? $e : false;
     }
     return false;
 }
 /**
  * Init function to start the rendering process
  */
 public function init()
 {
     $this->_shortname = Cii::getConfig('disqus_shortname');
     $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias('cii.assets.dist'), true, -1, YII_DEBUG);
     Yii::app()->clientScript->registerScriptFile($asset . (YII_DEBUG ? '/ciidisqus.js' : '/ciidisqus.min.js'), CClientScript::POS_END);
     if ($this->content != false) {
         $this->renderCommentBox();
     } else {
         $this->renderCommentCount();
     }
 }
示例#8
0
 /**
  * Overload the __getter so that it checks for data in the following order
  * 1) Pull From db/cache (Cii::getConfig now does caching of elements for improved performance)
  * 2) Check for __protected__ property, which we consider the default vlaue
  * 3) parent::__get()
  *
  * In order for this to work with __default__ values, the properties in classes that extend from this
  * MUST be protected. If they are public it will bypass this behavior.
  * 
  * @param  mixed $name The variable name we want to retrieve from the calling class
  * @return mixed
  */
 public function __get($name)
 {
     $data = Cii::getConfig($name);
     if ($data !== NULL && $data !== "" && !isset($this->attributes[$name])) {
         return $data;
     }
     if (property_exists($this, $name)) {
         return $this->{$name};
     }
     return parent::__get($name);
 }
示例#9
0
 /**
  * Handle CDN related Uploads
  * @return string
  */
 private function _uploadCDNFile()
 {
     Yii::import('ext.opencloud.OpenCloud');
     if (Cii::getConfig('useRackspaceCDN')) {
         $openCloud = new OpenCloud(Cii::getConfig('openstack_username'), Cii::decrypt(Cii::getConfig('openstack_apikey')), true, NULL, Cii::getConfig('openstack_region'));
     } else {
         $openCloud = new OpenCloud(Cii::getConfig('openstack_username'), Cii::decrypt(Cii::getConfig('openstack_apikey')), false, Cii::getConfig('openstack_identity'), Cii::getConfig('openstack_region'));
     }
     $container = $openCloud->getContainer(Cii::getConfig('openstack_container'));
     $this->_result = $openCloud->uploadFile($container);
     return $this->_handleResourceUpload($this->_result['url'] . '/' . $this->_result['filename']);
 }
示例#10
0
 public function init()
 {
     echo CHtml::openTag('div', array('class' => 'comments', 'id' => 'comment'));
     if (Cii::getConfig('useDisqusComments')) {
         echo CHtml::tag('div', array('id' => 'disqus_thread'), NULL);
     } else {
         if (Cii::getConfig('useDiscourseComments')) {
             echo CHtml::tag('div', array('id' => 'discourse-comments'), NULL);
         } else {
             echo CHtml::tag('div', array('id' => 'ciims_comments'), NULL);
         }
     }
     echo CHtml::closeTag('div');
 }
示例#11
0
 /**
  * Overrides processRules, allowing us to inject our own ruleset into the URL Manager
  * Takes no parameters
  **/
 protected function processRules()
 {
     $this->addBasicRules();
     $this->cacheRules('content', $this->contentUrlRulesId);
     $this->cacheRules('categories', $this->categoriesUrlRulesId);
     // Allow Sphinx Search settings to be dynamically via CiiSettings
     if (Cii::getConfig('sphinx_enabled')) {
         $this->rules['/search/<page:\\d+>'] = '/site/search';
         $this->rules['/search'] = '/site/search';
     }
     // Append our cache rules BEFORE we run the defaults
     $this->rules['<controller:\\w+>/<action:\\w+>/<id:\\d+>'] = '<controller>/<action>';
     $this->rules['<controller:\\w+>/<action:\\w+>'] = '<controller>/<action>';
     return parent::processRules();
 }
示例#12
0
 /**
  * Provides functionality to make a comment
  */
 public function actionComment()
 {
     if (Yii::app()->request->isAjaxRequest && Cii::get($_POST, 'Comments')) {
         $comment = new Comments();
         $comment->attributes = array('user_id' => Yii::app()->user->id, 'content_id' => $_POST['Comments']['content_id'], 'comment' => $_POST['Comments']['comment'], 'parent_id' => Cii::get($_POST['Comments'], 'parent_id', 0), 'approved' => Cii::getConfig('autoApproveComments', 1) == null ? 1 : Cii::getConfig('autoApproveComments', 1));
         if ($comment->save()) {
             $content = Content::model()->findByPk($comment->content_id);
             // Pass the values as "now" for the comment view"
             $comment->created = $comment->updated = Yii::t('Dashboard.main', 'now');
             // Set the attributed id to make life easier...
             header("X-Attribute-Id: {$comment->id}");
             $this->renderPartial('/content/comments', array('count' => $content->comment_count, 'comment' => $comment, 'depth' => 0, 'md' => new CMarkdownParser()));
         } else {
             throw new CHttpException(400, Yii::t('Dashboard.main', 'There was an error saving your comment.'));
         }
     }
 }
 /**
  * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
  * Requests come in, are verified, and then pulled from the database dynamically
  * Shows all blog posts for a particular category_id
  * @param $id	- The content ID that we want to pull from the database
  **/
 public function actionIndex($id = NULL)
 {
     // Run a pre check of our data
     $this->beforeCiiAction($id);
     // Retrieve the data
     $category = Categories::model()->findByPk($id);
     // Set the layout
     $this->setLayout('default');
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
     $pageSize = Cii::getConfig('categoryPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
     $criteria->limit = $pageSize;
     $criteria->order = 'created DESC';
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
 }
示例#14
0
 /**
  * Sends an invite to a new user
  * @return boolean
  */
 public function invite()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = new Users();
     $user->attributes = array('email' => $this->email, 'firstName' => null, 'lastName' => null, 'displayName' => null, 'password' => null, 'user_role' => 5, 'status' => Users::PENDING_INVITATION);
     // Create a new user, but bypass validation
     if ($user->save(false)) {
         $meta = new UserMetadata();
         $meta->attributes = array('user_id' => $user->id, 'key' => 'invitationKey', 'value' => Cii::generateSafeHash());
         // If the key was savedm send the email out
         if ($meta->save()) {
             $emailSettings = new EmailSettings();
             $emailSettings->send($user, Yii::t('ciims.models.InvitationForm', "You've Been Invited..."), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.invite', array('user' => $user, 'hash' => $meta->value), true, true);
             return true;
         }
         $user->delete();
     }
     return false;
 }
示例#15
0
 /**
  * Provides functionality to view a given profile
  * @param  int 	  $id          The ID belonging to the user
  * @param  string $username    The user's display name. This isn't super necessary, it just is better for SEO
  */
 public function actionIndex($id = NULL, $username = NULL)
 {
     // If an ID isn't provided, throw an error
     if ($id === NULL) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     // For SEO, if the display name isn't in the url, reroute it
     if ($id !== NULL && $username === NULL) {
         $model = Users::model()->findByPk($id);
         if ($model === NULL || $model->status == 0) {
             throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
         } else {
             $this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\\da-z]/i', '', $model->username));
         }
     }
     $model = Users::model()->findByPk($id);
     // Don't allow null signings or invalidated users to pollute our site
     if ($model->status == 0) {
         throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
     }
     $this->pageTitle = Yii::t('ciims.controllers.Profile', 'User {{user}} - CiiMS | {{sitename}}', array('{{user}}' => $model->name, '{{sitename}}' => Cii::getConfig('name', Yii::app()->name)));
     $this->render('index', array('model' => $model, 'md' => new CMarkdownParser()));
 }
示例#16
0
 /**
  * getTweets callback method
  * @param  $_POST  $postData Data supplied over post
  */
 public function getTweets($postData = NULL)
 {
     header("Content-Type: application/json");
     Yii::import('ext.twitteroauth.*');
     try {
         $connection = new TwitterOAuth(Cii::getConfig('ha_twitter_key', NULL, NULL), Cii::getConfig('ha_twitter_secret', NULL, NULL), Cii::getConfig('ha_twitter_accessToken', NULL, NULL), Cii::getConfig('ha_twitter_accessTokenSecret', NULL, NULL));
         $tweets = Yii::app()->cache->get($this->theme . '_settings_tweets');
         if ($tweets == false) {
             $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={$this->twitterHandle}&include_rts=false&exclude_replies=true&count={$this->twitterTweetsToFetch}");
             foreach ($tweets as &$tweet) {
                 $tweet->text = preg_replace("/([\\w]+\\:\\/\\/[\\w-?&;#~=\\.\\/\\@]+[\\w\\/])/", "<a target=\"_blank\" href=\"\$1\">\$1</a>", $tweet->text);
                 $tweet->text = preg_replace("/#([A-Za-z0-9\\/\\.]*)/", "<a target=\"_new\" href=\"http://twitter.com/search?q=\$1\">#\$1</a>", $tweet->text);
                 $tweet->text = preg_replace("/@([A-Za-z0-9\\/\\.]*)/", "<a href=\"http://www.twitter.com/\$1\">@\$1</a>", $tweet->text);
             }
             // Cache the result for 15 minutes
             if (!isset($tweets->errors)) {
                 Yii::app()->cache->set($this->theme . '_settings_tweets', $tweets, 900);
             }
         }
         echo CJSON::encode($tweets);
     } catch (Exception $e) {
         echo CJSON::encode(array('errors' => array(array('message' => $e->getMessage()))));
     }
 }
示例#17
0
 /**
  * No routing action
  */
 public function actionNR()
 {
     $themeName = Cii::getConfig('theme', 'default');
     if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName . DS . 'Theme.php')) {
         Yii::import('webroot.themes.' . $themeName . '.Theme');
         $theme = new Theme();
     }
     if ($theme->noRouting !== false) {
         $this->render('index');
     } else {
         throw new CHttpException(404);
     }
 }
示例#18
0
<?php

echo $user->displayName;
?>
,<br /><br />
<?php 
echo Yii::t('DefaultTheme', 'You recently notified us that you forgot your password for the following blog: {{blog}}. To reset your password, {{clickhere}} and follow the instructions on the reset page. This link is valid for 15 minutes.', array('{{blog}}' => CHtml::link(Cii::getConfig('name', Yii::app()->name), Yii::app()->createAbsoluteUrl('/')), '{{clickhere}}' => CHtml::link(Yii::t('DefaultTheme', 'click here'), Yii::app()->createAbsoluteUrl('/forgot/' . $hash))));
?>
<br /><br />
<?php 
echo Yii::t('DefaultTheme', 'Thank you.');
?>
<br /><br />
<?php 
echo Yii::t('DefaultTheme', 'P.S. If you did not request this email, you may safely ignore it.');
示例#19
0
?>
				</span>
				<span class="separator">⋅</span> 
			</span> 
			<span class="minor-meta-wrap">
				<span class="blog-categories minor-meta"><strong>in </strong>
				<span>
					<?php 
echo CHtml::link(CHtml::encode($content->category->name), Yii::app()->createUrl($content->category->slug));
?>
				</span> 
				<span class="separator">⋅</span> 
			</span> 					
			<span class="comment-container">
				<?php 
if (Cii::getConfig('useDisqusComments')) {
    ?>
					<?php 
    echo CHtml::link(0, Yii::app()->createUrl($content->slug) . '#disqus_thread') . ' ' . Yii::t('DefaultTheme', 'Comments');
    ?>
				<?php 
} else {
    ?>
					<?php 
    echo Yii::t('DefaultTheme', '{{count}} Comments', array('{{count}}' => $content->getCommentCount()));
    ?>
				<?php 
}
?>
				
			</span>
示例#20
0
 /**
  * Renders the data item list.
  */
 public function renderItems()
 {
     echo CHtml::openTag('div', array('class' => 'sidebar'));
     echo CHtml::openTag($this->itemsTagName, array('class' => $this->itemsCssClass, 'id' => 'main')) . "\n";
     echo CHtml::openTag('div', array('class' => 'content'));
     echo CHtml::openTag('div', array('class' => 'post post-header'));
     echo CHtml::tag('h6', array('class' => 'pull-left'), 'Posts');
     if (Yii::app()->user->role !== 7) {
         echo CHtml::link(NULL, Yii::app()->createUrl('/dashboard/content/save'), array('class' => 'icon-plus pull-right'));
     }
     echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
     echo CHtml::closeTag('div');
     $data = $this->dataProvider->getData();
     if (($n = count($data)) > 0) {
         $owner = $this->getOwner();
         $viewFile = $owner->getViewFile($this->itemView);
         $j = 0;
         foreach ($data as $i => $item) {
             $data = $this->viewData;
             $data['index'] = $i;
             $data['data'] = $item;
             $data['widget'] = $this;
             $owner->renderFile($viewFile, $data);
             if ($j++ < $n - 1) {
                 echo $this->separator;
             }
         }
     } else {
         $this->renderEmptyText();
     }
     echo CHtml::closeTag('div');
     echo CHtml::closeTag($this->itemsTagName);
     $this->renderPager();
     echo CHtml::closeTag('div');
     echo CHtml::openTag('div', array('class' => 'body-content preview-container'));
     $this->renderSorter();
     echo CHtml::openTag('div', array('class' => 'preview nano', 'id' => 'preview'));
     echo CHtml::openTag('div', array('class' => 'content'));
     $this->render('preview', array('model' => $this->preview));
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::openTag('div', array('class' => 'content-sidebar'));
     // Header
     echo CHtml::openTag("div", array('class' => 'comments-header'));
     echo CHtml::tag('span', array('class' => 'title pull-left'), Yii::t('Dashboard.main', 'Comments'));
     echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
     echo CHtml::closeTag('div');
     // Sharebox
     echo CHtml::openTag('div', array('class' => 'comment-box-main nano', 'style' => 'display: none'));
     echo CHtml::openTag('div', array('class' => 'content'));
     if (Cii::getConfig('useDisqusComments')) {
         echo CHtml::tag('div', array('id' => 'disqus_thread'), NULL);
     } else {
         echo CHtml::openTag('div', array('id' => 'sharebox', 'class' => 'comment-box'));
         echo CHtml::openTag('div', array('id' => 'a'));
         echo CHtml::tag('div', array('id' => 'textbox', 'contenteditable' => 'true'), NULL);
         echo CHtml::tag('div', array('id' => 'close'), NULL);
         echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
         echo CHtml::closeTag('div');
         echo CHtml::tag('div', array('id' => 'b'), NULL);
         echo CHtml::tag('button', array('id' => 'submit-comment', 'class' => 'btn btn-success sharebox-submit'), Yii::t('DefaultTheme', 'Submit'));
         echo CHtml::closeTag('div');
     }
     echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
     echo CHtml::tag('div', array('class' => 'comment-container'));
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     if (Cii::getConfig('useDisqusComments')) {
         echo CHtml::tag('span', array('id' => 'disqus_shortname', 'style' => 'display: none'), Cii::getConfig('disqus_shortname'));
     }
 }
示例#21
0
 /**
  * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent
  * @return boolean
  */
 public function sendVerificationEmail()
 {
     $emailSettings = new EmailSettings();
     return $emailSettings->send($this->_user, Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'), 'base.themes.' . Cii::getConfig('theme', 'default') . '.views.email.email-change', array('key' => $this->setNewEmailChangeKey(), 'user' => $this->_user));
 }
示例#22
0
</fieldset>
<fieldset>
<?php 
foreach ($model->getThemes() as $theme => $options) {
    $attribute = $theme == 'desktop' ? 'theme' : $theme . 'Theme';
    $elements = array();
    $elementOptions = array('options' => array());
    // Allow themes to be empty for non desktop theme
    if ($attribute !== 'theme') {
        $elements = array(NULL);
        $elementOptions = array('options' => array(array('value' => NULL)));
    }
    foreach ($options as $k => $v) {
        $themeFolder = str_replace('webroot.themes.', '', $v['folder']);
        $elements[] = $themeFolder;
        // This image SHOULD be publicly accessible at this location assuming you have a half sane setup
        $elementOptions['options'][] = array('value' => $themeFolder, 'data-img-src' => Yii::app()->getBaseUrl(true) . '/themes/' . $themeFolder . '/default.png', 'selected' => Cii::getConfig($attribute) == $themeFolder ? 'selected' : null);
    }
    echo CHtml::openTag('div', array('class' => 'pure-form-group', 'style' => 'padding-bottom: 20px'));
    echo CHtml::tag('legend', array(), Cii::titleize($attribute));
    echo $form->dropDownListRow($model, $attribute, $elements, $elementOptions);
    if (count($options) == 0) {
        echo CHtml::tag('div', array('class' => 'row noItemsMessage'), CHtml::tag('span', array(), Yii::t('Dashboard.views', 'There are no themes installed for this category.')));
    }
    echo CHtml::closeTag('div');
}
?>
</fieldset>

<?php 
Yii::app()->getClientScript()->registerCssFile($this->asset . '/css/image-picker.css')->registerScriptFile($this->asset . '/js/image-picker.min.js', CClientScript::POS_END)->registerCss('no-labels', 'label { display: none; }');
示例#23
0
 /**
  * Retrieves view files for a particular path
  * @param  string $theme  The theme to reference
  * @param  string $type   The view type to lookup
  * @return array $files   An array of files
  */
 private function getFiles($theme = null, $type = 'views')
 {
     if ($theme === null) {
         $theme = Cii::getConfig('theme', 'default');
     }
     $folder = $type;
     if ($type == 'view') {
         $folder = 'content';
     }
     $returnFiles = array();
     if (!file_exists(YiiBase::getPathOfAlias('webroot.themes.' . $theme))) {
         $theme = 'default';
     }
     $files = Yii::app()->cache->get($theme . '-available-' . $type);
     if ($files === false) {
         $fileHelper = new CFileHelper();
         $files = $fileHelper->findFiles(Yii::getPathOfAlias('webroot.themes.' . $theme . '.' . $folder), array('fileTypes' => array('php'), 'level' => 0));
         Yii::app()->cache->set($theme . '-available-' . $type, $files);
     }
     foreach ($files as $file) {
         $f = str_replace('content', '', str_replace('/', '', str_replace('.php', '', substr($file, strrpos($file, '/') + 1))));
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
             $f = trim(substr($f, strrpos($f, '\\') + 1));
         }
         if (!in_array($f, array('all', 'password', '_post'))) {
             $returnFiles[$f] = $f;
         }
     }
     return $returnFiles;
 }
示例#24
0
文件: Users.php 项目: bartuspan/CiiMS
 /**
  * Sets some default values for the user record.
  * TODO: This should have been moved to CiiModel
  * @see CActiveRecord::beforeValidate()
  **/
 public function beforeValidate()
 {
     // If the password is nulled, or unchanged
     if ($this->password == NULL || $this->password == Cii::get($this->_oldAttributes, 'password', false)) {
         if (!$this->isNewRecord) {
             $this->password = $this->_oldAttributes['password'];
         }
     } else {
         $this->password = password_hash($this->password, PASSWORD_BCRYPT, array('cost' => Cii::getBcryptCost()));
         if (!$this->isNewRecord) {
             $emailSettings = new EmailSettings();
             $emailSettings->send($this, Yii::t('ciims.models.Users', 'CiiMS Password Change Notification'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.passwordchange', array('user' => $this));
         }
     }
     return parent::beforeValidate();
 }
示例#25
0
 /**
  * Creates a new user, and sends the appropriate messaging out
  * @return boolean
  */
 public function save($sendEmail = true)
 {
     if (!$this->validate()) {
         return false;
     }
     $this->_user = new Users();
     // Set the model attributes
     $this->_user->attributes = array('email' => $this->email, 'password' => $this->password, 'username' => $this->username, 'user_role' => 1, 'status' => $sendEmail ? Users::PENDING_INVITATION : Users::ACTIVE);
     // If we saved the user model, return true
     if ($this->_user->save()) {
         // This class my be extended by other modules, in which case we don't need to send an activation form if we don't want need it to.
         if ($sendEmail) {
             $meta = new UserMetadata();
             $meta->attributes = array('user_id' => $this->_user->id, 'key' => 'activationKey', 'value' => Cii::generateSafeHash());
             $meta->save();
             // Send the registration email
             $emailSettings = new EmailSettings();
             $emailSettings->send($this->_user, Yii::t('ciims.email', 'Activate Your Account'), 'base.themes.' . Cii::getConfig('theme', 'default') . '.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true);
         }
         return true;
     }
     return false;
 }
示例#26
0
 /**
  * Handles the creation and editing of Content models.
  * If no id is provided, a new model will be created. Otherwise attempt to edit
  * @param int $id   The ContentId of the model we want to manipulate
  */
 public function actionSave($id = NULL)
 {
     $version = 0;
     $theme = Cii::getConfig('theme', 'default');
     $viewFiles = $this->getViewFiles($theme);
     $layouts = $this->getLayouts($theme);
     // Editor Preferences
     $preferMarkdown = Cii::getConfig('preferMarkdown', false);
     if ($preferMarkdown == NULL) {
         $preferMarkdown = false;
     } else {
         $preferMarkdown = (bool) $preferMarkdown;
     }
     // Determine what we're doing, new model or existing one
     if ($id == NULL) {
         $model = new Content();
         $model->savePrototype();
         $this->redirect($this->createUrl('/dashboard/content/save/id/' . $model->id));
     } else {
         $model = Content::model()->findByPk($id);
         if ($model == NULL) {
             throw new CHttpException(400, Yii::t('Dashboard.main', 'We were unable to retrieve a post with that id. Please do not repeat this request again.'));
         }
         // Determine the version number based upon the count of existing rows
         // We do this manually to make sure we have the correct data
         $version = Content::model()->countByAttributes(array('id' => $id));
     }
     $role = Yii::app()->user->role;
     if ($role != 7 && $role != 9) {
         if ($model->author_id != Yii::app()->user->id) {
             throw new CHttpException(401, Yii::t('Dashboard.main', 'You are not authorized to perform this action.'));
         }
     }
     if (Cii::get($_POST, 'Content') !== NULL) {
         $model2 = new Content();
         $model2->attributes = Cii::get($_POST, 'Content', array());
         if (Cii::get($_POST['Content'], 'password', "") != "") {
             $model2->password = Cii::encrypt($_POST['Content']['password']);
         } else {
             $model2->password = "";
         }
         // For some reason this isn't setting with the other data
         $model2->extract = $_POST['Content']['extract'];
         $model2->id = $id;
         $model2->vid = $model->vid + 1;
         $model2->viewFile = Cii::get($_POST['Content'], 'view', 'blog');
         $model2->layoutFile = Cii::get($_POST['Content'], 'layout', 'blog');
         $model2->created = $_POST['Content']['created'];
         $model2->commentable = Cii::get($_POST['Content'], 'commentable', 1);
         $model2->type_id = Cii::get($_POST['Content'], 'type_id', 2);
         $model2->published = Cii::get($_POST['Content'], 'published', NULL);
         $time = strtotime($model2->published . $_POST['timezone']);
         $published = date('Y-m-d H:i:s', $time);
         $model2->published = $published;
         if ($model->author_id != Yii::app()->user->id) {
             $model2->author_id = $model->author_id;
         }
         // Prevent editors and collaborators from publishing acticles
         if ($role == 5 || $role == 7) {
             if ($model2->status == 1) {
                 $model2->status = 2;
             }
         }
         if ($model2->save()) {
             Yii::app()->user->setFlash('success', Yii::t('Dashboard.main', 'Content has been updated.'));
             // TODO: This should eventually be an Ajax Request as part of an APIController rather than being baked into this.
             if (Yii::app()->request->isAjaxRequest) {
                 echo CJSON::encode($model2->attributes);
                 return true;
             }
             $this->redirect(array('save', 'id' => $model2->id));
         } else {
             foreach ($model2->attributes as $k => $v) {
                 $model->{$k} = $v;
             }
             $model->vid = $model2->vid - 1;
             $model->addErrors($model2->getErrors());
             Yii::app()->user->setFlash('error', Yii::t('Dashboard.main', 'There was an error saving your content. Please try again.'));
         }
     }
     $this->render('save', array('model' => $model, 'id' => $id, 'version' => $version, 'preferMarkdown' => $preferMarkdown, 'views' => $viewFiles, 'layouts' => $layouts, 'canPublish' => Yii::app()->user->role != 7 && Yii::app()->user->role != 5));
 }
示例#27
0
	<div class="settings-container">
		<div class="sidebar">
			<div class="header">
				<h3><?php 
echo Yii::t('Dashboard.views', 'Settings');
?>
</h3>
			</div>
			<div id="main" class="nano">
				<div class="content">
					<?php 
$theme = Cii::getConfig('theme', 'default');
$displayTheme = file_exists(Yii::getPathOfAlias('webroot.themes.' . $theme) . DIRECTORY_SEPARATOR . 'Theme.php');
$mobileTheme = Cii::getConfig('mobileTheme');
$displayMobileTheme = file_exists(Yii::getPathOfAlias('webroot.themes.' . $mobileTheme) . DIRECTORY_SEPARATOR . 'Theme.php');
$tabletTheme = Cii::getConfig('tabletTheme');
$displayTabletTheme = file_exists(Yii::getPathOfAlias('webroot.themes.' . $tabletTheme) . DIRECTORY_SEPARATOR . 'Theme.php');
$this->widget('zii.widgets.CMenu', array('htmlOptions' => array('class' => 'menu'), 'items' => array(array('url' => $this->createUrl('/dashboard/settings'), 'label' => Yii::t('Dashboard.views', 'General'), 'itemOptions' => array('class' => 'icon-gears'), 'active' => $this->id == 'settings' && $this->action->id == 'index' ? true : false), array('url' => $this->createUrl('/dashboard/users'), 'label' => Yii::t('Dashboard.views', 'Users'), 'itemOptions' => array('class' => 'icon-group'), 'active' => $this->id == 'users' ? true : false), array('url' => $this->createUrl('/dashboard/categories'), 'label' => Yii::t('Dashboard.views', 'Categories'), 'itemOptions' => array('class' => 'icon-list'), 'active' => $this->id == 'categories' ? true : false), array('url' => $this->createUrl('/dashboard/settings/analytics'), 'label' => Yii::t('Dashboard.views', 'Analytics'), 'itemOptions' => array('class' => 'icon-bar-chart'), 'active' => $this->id == 'analytics' || $this->id == 'settings' && $this->action->id == 'analytics' ? true : false), array('url' => $this->createUrl('/dashboard/settings/appearance'), 'label' => Yii::t('Dashboard.views', 'Appearance'), 'itemOptions' => array('class' => 'icon-eye-open'), 'active' => $this->id == 'settings' && $this->action->id == 'appearance' ? true : false), array('url' => $this->createUrl('/dashboard/settings/email'), 'label' => Yii::t('Dashboard.views', 'Email'), 'itemOptions' => array('class' => 'icon-envelope-alt'), 'active' => $this->id == 'settings' && $this->action->id == 'email' ? true : false), array('url' => $this->createUrl('/dashboard/settings/social'), 'label' => Yii::t('Dashboard.views', 'Social'), 'itemOptions' => array('class' => 'icon-twitter'), 'active' => $this->id == 'settings' && $this->action->id == 'social' ? true : false), array('url' => $this->createUrl('/dashboard/settings/cards'), 'label' => Yii::t('Dashboard.views', 'Dashboard Cards'), 'itemOptions' => array('class' => 'icon-th-large'), 'active' => $this->id == 'settings' && $this->action->id == 'cards' ? true : false), array('url' => $this->createUrl('/dashboard/settings/system'), 'label' => Yii::t('Dashboard.views', 'System'), 'itemOptions' => array('class' => 'icon-cloud'), 'active' => $this->id == 'settings' && $this->action->id == 'system' ? true : false), array('url' => $this->createUrl('/dashboard/settings/theme'), 'label' => Yii::t('Dashboard.views', 'Theme'), 'itemOptions' => array('style' => $displayTheme ?: 'display: none', 'class' => 'icon-desktop'), 'active' => $this->id == 'settings' && $this->action->id == 'theme' && $this->themeType == 'desktop' ? true : false), array('url' => $this->createUrl('/dashboard/settings/theme/type/mobile'), 'label' => Yii::t('Dashboard.views', 'Mobile Theme'), 'itemOptions' => array('style' => $displayMobileTheme ?: 'display: none', 'class' => 'icon-mobile-phone'), 'active' => $this->id == 'settings' && $this->action->id == 'theme' && $this->themeType == 'mobile' ? true : false), array('url' => $this->createUrl('/dashboard/settings/theme/type/tablet'), 'label' => Yii::t('Dashboard.views', 'Tablet Theme'), 'itemOptions' => array('style' => $displayTabletTheme ?: 'display: none', 'class' => 'icon-tablet'), 'active' => $this->id == 'settings' && $this->action->id == 'theme' && $this->themeType == 'tablet' ? true : false))));
?>
				</div>
			</div>
		</div>
		<div class="body-content">
			<?php 
echo $content;
?>
		</div>
		<style>
			.icon-twitter {
				display: block !important;
			}
示例#28
0
 /**
  * Enables users who have recieved an invitation to setup a new account
  * @param string $id	The activation id the of the user that we want to activate
  */
 public function actionAcceptInvite($id = NULL)
 {
     $this->layout = '//layouts/main';
     $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation'))));
     if ($id === NULL) {
         throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
     }
     // Make sure we have a user first
     $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id));
     if ($meta === NULL) {
         throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
     }
     $model = new InviteForm();
     $model->email = Users::model()->findByPk($meta->user_id)->email;
     if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) {
         $model->attributes = Cii::get($_POST, 'InviteForm', NULL);
         $model->id = $meta->user_id;
         if ($model->acceptInvite()) {
             $meta->delete();
             return $this->render('invitesuccess');
         }
     }
     $this->render('acceptinvite', array('model' => $model));
 }
示例#29
0
 public function actionList()
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Content', 'All Content'));
     $this->setLayout('default');
     $this->breadcrumbs = array(Yii::t('ciims.controllers.Content', 'Blogroll'));
     $data = array();
     $pages = array();
     $itemCount = 0;
     $pageSize = Cii::getConfig('contentPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition('password = ""');
     $criteria->order = 'published DESC';
     $criteria->limit = $pageSize;
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('all', array('data' => $data, 'itemCount' => $itemCount, 'pages' => $pages));
 }
示例#30
0
文件: all.php 项目: fandikurnia/CiiMS
</div>

<?php 
if (count($data)) {
    ?>
	<?php 
    $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array('url' => isset($url) ? $url : 'blog', 'contentSelector' => '#posts', 'pages' => $pages, 'defaultCallback' => "js:function(response, data) {\n\t    \tDefaultTheme.infScroll(response, data);\n\t    \tsetTimeout(function() {\n\t    \t\tDefaultTheme.Blog.loadDisqusCommentCount(disqus_shortname); \n\t    \t}, 500);\n \t\t}"));
    ?>
	<?php 
    Yii::app()->clientScript->registerScript('unbind-infinite-scroll', "DefaultTheme.loadAll();");
    ?>
	<?php 
    if (Cii::getConfig('useDisqusComments')) {
        ?>
		<?php 
        $shortname = Cii::getConfig('disqus_shortname');
        ?>
		<?php 
        Yii::app()->clientScript->registerScript('loadComments', "DefaultTheme.Blog.loadDisqusCommentCount(\"{$shortname}\");");
        ?>
	<?php 
    }
} else {
    ?>
	<div class="alert alert-info">
		<?php 
    echo Yii::t('DefaultTheme', "{{woah}} It looks like there aren't any posts in this category yet. Why don't you check out some of our other pages or check back later?", array('{{woah}}' => CHtml::tag('strong', array(), Yii::t('DefaultTheme', 'Woah!'))));
    ?>
	</div>
<?php 
}