Inheritance: extends Modules
 /**
  * Change Case status using select-box
  */
 public function actionChangeStatus()
 {
     // check if user has permissions to changeStatusCases
     if (Yii::app()->user->checkAccess('changeStatusCases')) {
         // verify is request was made via post ajax
         if (Yii::app()->request->isAjaxRequest && isset($_POST)) {
             // get Cases object model
             $model = $this->loadModel($_REQUEST['id']);
             // set new status
             $model->status_id = $_POST['changeto'];
             // validate and save
             if ($model->save()) {
                 // save log
                 $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseStatusChanged', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
                 Logs::model()->saveLog($attributes);
                 // create comment to let then know that some user change the case status
                 $modelComment = new Comments();
                 $modelComment->comment_date = date("Y-m-d G:i:s");
                 $modelComment->comment_text = Status::STATUS_COMMENT . ": " . $model->Status->status_id;
                 $modelComment->user_id = Yii::app()->user->id;
                 $modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id;
                 $modelComment->comment_resourceid = $model->case_id;
                 $modelComment->save(false);
                 // prepare email template for each project manager
                 Yii::import('application.extensions.phpMailer.yiiPhpMailer');
                 $mailer = new yiiPhpMailer();
                 $subject = Yii::t('email', 'CaseStatusChange') . " - " . $model->case_name;
                 //$Users = Users::model()->with('Clients')->findManagersByProject($model->project_id);
                 $Users = Projects::model()->findAllUsersByProject($model->project_id);
                 $recipientsList = array();
                 foreach ($Users as $client) {
                     $recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email);
                 }
                 // load template
                 $str = $this->renderPartial('//templates/cases/StatusChanged', array('case' => $model, 'user' => Users::model()->findByPk(Yii::app()->user->id), 'urlToCase' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('cases/view', array('id' => $model->case_id)), 'typeNews' => $model->status_id == Status::STATUS_ACCEPTED || $model->status_id == Status::STATUS_TOREVIEW ? 'buenas' : 'malas', 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
                 $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
                 $output = Yii::t('cases', 'StatusChanged');
             } else {
                 $output = Yii::t('cases', 'StatusError');
             }
             echo $output;
             Yii::app()->end();
         } else {
             throw new CHttpException(403, Yii::t('site', '403_Error'));
         }
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
Ejemplo n.º 2
0
 public function submitComment()
 {
     $model = new Comments();
     $model->submitComment();
     // Now we redirect to the book, so it shows the new comment
     header('Location: index.php?action=showbook&id=' . $_SESSION['bookid']);
 }
 public function newComment()
 {
     // POST İLE GÖNDERİLEN DEĞERLERİ ALALIM.
     $postData = Input::all();
     // FORM KONTROLLERİNİ BELİRLEYELİM
     $rules = array('question_id' => 'required|integer', 'comment' => 'required');
     // HATA MESAJLARINI OLUŞTURALIM
     $messages = array('question_id.required' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'question_id.integer' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'comment.required' => 'Lütfen yanıtınızı yazın');
     // KONTROL (VALIDATION) İŞLEMİNİ GERÇEKLEŞTİRELİM
     $validator = Validator::make($postData, $rules, $messages);
     // EĞER VALİDASYON BAŞARISIZ OLURSA HATALARI GÖSTERELİM
     if ($validator->fails()) {
         // KULLANICIYI SORU SAYFASINA GERİ GÖNDERELİM
         return Redirect::to(URL::previous())->withErrors($validator->messages());
     } else {
         // SORUYU VERİTABANINA EKLEYELİM
         $comment = new Comments();
         $comment->user_id = Auth::user()->id;
         $comment->question_id = $postData['question_id'];
         $comment->comment = e(trim($postData['comment']));
         $comment->created_at = date('Y-m-d H:i:s');
         $comment->created_ip = Request::getClientIp();
         $comment->save();
         // KULLANICIYI YENİDEN SORUYA YÖNLENDİRELİM
         return Redirect::to(URL::previous());
     }
 }
Ejemplo n.º 4
0
 /**
  * Добавление / редактирование комментариев
  */
 public function actionSave_comment()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createAbsoluteUrl('base'));
     }
     // Редактирование или добавление новой
     if (isset($_GET['idComment'])) {
         $model = Comments::model()->findByPk($_GET['idComment']);
     } else {
         $model = new Comments();
     }
     if (isset($_POST['idArticle']) && isset($_POST['text']) && isset($_POST['idAuthor'])) {
         $model->idArticle = $_POST['idArticle'];
         $model->text = $_POST['text'];
         $model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser'];
         $model->typeUser = $model->idUser == $_POST['idAuthor'] ? 'author' : (empty($this->_user) ? 'admin' : 'user');
         if ($model->save()) {
             if (Yii::app()->request->isAjaxRequest) {
                 $criteria = new CDbCriteria();
                 $criteria->with = array('idUser0');
                 $criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1';
                 $criteria->params = array(':idArticle' => $_POST['idArticle']);
                 $comments = Comments::model()->findAll($criteria);
                 $commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50)));
                 $listComments = $this->renderPartial('_list_comments', array('dataProvider' => $commentsDataProvider), true);
                 echo CJSON::encode(array('listComments' => $listComments));
                 exit;
             }
         }
     }
 }
function module_most_commented($mod_reference, $module_params)
{
	global $smarty;
	global $commentslib;

	if (!isset($commentslib)) {
		include_once ('lib/comments/commentslib.php');
		$commentslib = new Comments();
	}
	$type = 'wiki';
	if (isset($module_params['objectType'])) {
		$type = $module_params['objectType'];
		if ($type != 'article' && $type != 'blog' && $type != 'wiki') {
			//If parameter is not properly set then default to wiki
			$type = 'wiki';
		}
	}
	
	$result = $commentslib->order_comments_by_count($type, isset($module_params['objectLanguageFilter']) ? $module_params['objectLanguageFilter'] : '', $mod_reference['rows']);
	if ($result === false) {
		$smarty->assign('module_error', tra('Feature disabled'));
		return;
	}
	$smarty->assign('modMostCommented', $result['data']);
	$smarty->assign('modContentType', $type);
}
Ejemplo n.º 6
0
function smarty_function_poll($params, &$smarty)
{
    global $polllib;
    global $dbTiki;
    global $commentslib;
    global $feature_poll_comments;
    extract($params);
    // Param = zone
    if (!is_object($polllib)) {
        include_once 'lib/polls/polllib_shared.php';
    }
    include_once 'lib/commentslib.php';
    if (isset($rate)) {
        if (!$tikilib->page_exists($rate)) {
            return false;
        }
    }
    if (empty($id)) {
        $id = $polllib->get_random_active_poll();
    }
    if ($id) {
        $menu_info = $polllib->get_poll($id);
        $channels = $polllib->list_poll_options($id);
        if ($feature_poll_comments == 'y') {
            $commentslib = new Comments($dbTiki);
            $comments_count = $commentslib->count_comments("poll:" . $menu_info["pollId"]);
        }
        $smarty->assign('comments', $comments_count);
        $smarty->assign('ownurl', 'tiki-poll_results.php?pollId=' . $id);
        $smarty->assign('menu_info', $menu_info);
        $smarty->assign('channels', $channels);
        $smarty->display('tiki-poll.tpl');
    }
}
Ejemplo n.º 7
0
 /** Comments on your records
  */
 public function onmineAction()
 {
     $params = $this->_getAllParams();
     $this->view->params = $params;
     $comments = new Comments();
     $this->view->comments = $comments->getCommentsOnMyRecords($this->getIdentityForForms(), $this->_getParam('page'), $this->_getParam('approval'));
 }
Ejemplo n.º 8
0
 public function actionSendMail()
 {
     if (!empty($_POST)) {
         Yii::import('ext.yii-mail.YiiMailMessage');
         $message = new YiiMailMessage();
         $message->setBody($_POST['content']);
         $message->subject = $_POST['subject'];
         $message->from = $_POST['email'];
         $message->to = Yii::app()->params['adminEmail'];
         if (Yii::app()->mail->send($message)) {
             $model = new Comments();
             $model->title = $_POST['subject'];
             $model->content = $_POST['content'];
             $model->email = $_POST['email'];
             $model->name = $_POST['fullName'];
             $model->phone = $_POST['phone'];
             $model->created = time();
             if ($model->save()) {
                 return jsonOut(array('error' => false, 'message' => 'Cảm ơn bạn đã gửi thông tin, chúng tôi sẽ phản hồi cho bạn trong thời gian sớm nhất!'));
             } else {
                 return json_encode(array('error' => true, 'message' => 'Lỗi hệ thống, gửi thông tin không thành công.'));
             }
         } else {
             return json_encode(array('error' => true, 'message' => 'Gửi thông tin không thành công'));
         }
     }
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the last comments
     $comments = new Comments(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     $mycomments = $comments->getLastComments();
     $data = new Data();
     // Prepare the comments for output
     foreach ($mycomments as &$comment) {
         $time = strtotime($comment['timestamp']);
         $item = $data->getItem($comment['source_id'], $comment['item_id']);
         $comment['item'] = $item;
         $comment['when'] = Stuffpress_Date::ago($time, "j M y");
         $comment['comment'] = str_replace("\n", " ", $comment['comment']);
         if (strlen($comment['comment']) > 50) {
             $comment['comment'] = mb_substr($comment['comment'], 0, 47) . "...";
         }
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Latest comments";
     // Prepare the view for rendering
     $this->view->comments = $mycomments;
 }
Ejemplo n.º 10
0
 public function deleteComment(Comments $comment)
 {
     /** @var myModel $this */
     if (method_exists($this, 'decreaseCount')) {
         $this->decreaseCount('commentCount');
     }
     return $comment->delete();
 }
Ejemplo n.º 11
0
 /**
  * Вывод инфы о бане
  * @param integer $id ID бана
  */
 public function actionView($id)
 {
     // Подгружаем комментарии и файлы
     $files = new Files();
     //$this->performAjaxValidation($files);
     $files->unsetAttributes();
     $comments = new Comments();
     $comments->unsetAttributes();
     // Подгружаем баны
     $model = Bans::model()->with('admin')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $geo = false;
     // Проверка прав на просмотр IP
     $ipaccess = Webadmins::checkAccess('ip_view');
     if ($ipaccess) {
         $geo = array('city' => 'Н/А', 'region' => 'Не определен', 'country' => 'Не определен', 'lat' => 0, 'lng' => 0);
         $get = @file_get_contents('http://ipgeobase.ru:7020/geo?ip=' . $model->player_ip);
         if ($get) {
             $xml = @simplexml_load_string($get);
             if (!empty($xml->ip)) {
                 $geo['city'] = $xml->ip->city;
                 $geo['region'] = $xml->ip->region;
                 $geo['country'] = $xml->ip->country;
                 $geo['lat'] = $xml->ip->lat;
                 $geo['lng'] = $xml->ip->lng;
             }
         }
     }
     // Добавление файла
     if (isset($_POST['Files'])) {
         // Задаем аттрибуты
         $files->attributes = $_POST['Files'];
         $files->bid = intval($id);
         if ($files->save()) {
             $this->refresh();
         }
     }
     // Добавление комментария
     if (isset($_POST['Comments'])) {
         //exit(print_r($_POST['Comments']));
         $comments->attributes = $_POST['Comments'];
         $comments->bid = $id;
         if ($comments->save()) {
             $this->refresh();
         }
     }
     // Выборка комментариев
     $c = new CActiveDataProvider($comments, array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
     // Выборка файлов
     $f = new CActiveDataProvider(Files::model(), array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
     // История банов
     $history = new CActiveDataProvider('Bans', array('criteria' => array('condition' => '`bid` <> :hbid AND (`player_ip` = :hip OR `player_id` = :hid)', 'params' => array(':hbid' => $id, ':hip' => $model->player_ip, ':hid' => $model->player_id)), 'pagination' => array('pageSize' => 5)));
     // Вывод всего на вьюху
     $this->render('view', array('geo' => $geo, 'ipaccess' => $ipaccess, 'model' => $model, 'files' => $files, 'comments' => $comments, 'f' => $f, 'c' => $c, 'history' => $history));
 }
Ejemplo n.º 12
0
 /**
  * 这里可以作为一个通用的保存评论的方法来使用
  * @param myModel $model
  * @param $data
  */
 protected function saveCommentTo(myModel $model, $data)
 {
     $comment = new Comments();
     $comment->content = $data['content'];
     $comment->commentable_id = $model->id;
     $comment->commentable_type = get_class($model);
     $comment->user_id = $this->auth->id;
     $comment->save();
 }
Ejemplo n.º 13
0
 public function editCommentAction(Sites $site, Comments $comment)
 {
     if ($this->request->isPost()) {
         $comment->update($this->request->getPost());
         $this->redirectByRoute(['for' => 'sites.show', 'site' => $site->id]);
     }
     $this->view->comment = $comment;
     $this->view->form = myForm::buildCommentForm($site, $comment);
 }
Ejemplo n.º 14
0
 public function editCommentAction(Episodes $episode, Comments $comment)
 {
     if ($this->request->isPost()) {
         $comment->update($this->request->getPost());
         return $this->redirectByRoute(['for' => 'movies.showEpisode', 'movie' => $episode->getMovie()->id, 'episode' => $episode->id]);
     }
     $this->view->comment = $comment;
     $this->view->form = myForm::buildCommentForm($episode, $comment);
 }
Ejemplo n.º 15
0
/**
 *  Computes the alternate homes for each feature
 *		(used in admin general template)
 * 
 * @access public
 * @return array of url's and labels of the alternate homepages
 */
function feature_home_pages($partial = false)
{
    global $prefs, $tikilib, $commentslib;
    $tikiIndex = array();
    //wiki
    $tikiIndex['tiki-index.php'] = tra('Wiki');
    // Articles
    if (!$partial && $prefs['feature_articles'] == 'y') {
        $tikiIndex['tiki-view_articles.php'] = tra('Articles');
    }
    // Blog
    if (!$partial && $prefs['feature_blogs'] == 'y') {
        if ($prefs['home_blog'] != '0') {
            global $bloglib;
            require_once 'lib/blogs/bloglib.php';
            $hbloginfo = $bloglib->get_blog($prefs['home_blog']);
            $home_blog_name = substr($hbloginfo['title'], 0, 20);
        } else {
            $home_blog_name = tra('Set blogs homepage first');
        }
        $tikiIndex['tiki-view_blog.php?blogId=' . $prefs['home_blog']] = tra('Blog:') . $home_blog_name;
    }
    // Image gallery
    if (!$partial && $prefs['feature_galleries'] == 'y') {
        if ($prefs['home_gallery'] != '0') {
            $hgalinfo = $tikilib->get_gallery($prefs['home_gallery']);
            $home_gal_name = substr($hgalinfo["name"], 0, 20);
        } else {
            $home_gal_name = tra('Set Image gal homepage first');
        }
        $tikiIndex['tiki-browse_gallery.php?galleryId=' . $prefs['home_gallery']] = tra('Image Gallery:') . $home_gal_name;
    }
    // File gallery
    if (!$partial && $prefs['feature_file_galleries'] == 'y') {
        $filegallib = TikiLib::lib('filegal');
        $hgalinfo = $filegallib->get_file_gallery($prefs['home_file_gallery']);
        $home_gal_name = substr($hgalinfo["name"], 0, 20);
        $tikiIndex['tiki-list_file_gallery.php?galleryId=' . $prefs['home_file_gallery']] = tra('File Gallery:') . $home_gal_name;
    }
    // Forum
    if (!$partial && $prefs['feature_forums'] == 'y') {
        require_once 'lib/comments/commentslib.php';
        if (!isset($commentslib)) {
            $commentslib = new Comments();
        }
        if ($prefs['home_forum'] != '0') {
            $hforuminfo = $commentslib->get_forum($prefs['home_forum']);
            $home_forum_name = substr($hforuminfo['name'], 0, 20);
        } else {
            $home_forum_name = tra('Set Forum homepage first');
        }
        $tikiIndex['tiki-view_forum.php?forumId=' . $prefs['home_forum']] = tra('Forum:') . $home_forum_name;
    }
    // Custom home
    $tikiIndex['tiki-custom_home.php'] = tra('Custom home');
    return $tikiIndex;
}
Ejemplo n.º 16
0
 public function addCommentBy(Users $user, $data)
 {
     $comment = new Comments();
     $comment->content = $data['content'];
     $comment->commentable_id = $this->id;
     $comment->commentable_type = get_class($this);
     $comment->user_id = $user->id;
     $comment->save();
     return $this;
 }
Ejemplo n.º 17
0
 function _install()
 {
     global $dbTiki;
     require_once 'lib/comments/commentslib.php';
     $comments = new Comments($dbTiki);
     $data = $this->getData();
     $this->replaceReferences($data);
     $attConverter = new Tiki_Profile_ValueMapConverter(array('none' => 'att_no', 'everyone' => 'att_all', 'allowed' => 'att_perm', 'admin' => 'att_admin'));
     $id = $comments->replace_forum(0, $data['name'], $data['description'], $data['enable_flood_control'], $data['flood_interval'], $data['moderator'], $data['mail'], $data['enable_inbound_mail'], $data['enable_prune_unreplied'], $data['prune_unreplied_max_age'], $data['enable_prune_old'], $data['prune_max_age'], $data['per_page'], $data['topic_order'], $data['thread_order'], $data['section'], $data['list_topic_reads'], $data['list_topic_replies'], $data['list_topic_points'], $data['list_topic_last_post'], $data['list_topic_author'], $data['enable_vote_threads'], $data['show_description'], $data['inbound_pop_server'], $data['inbound_pop_port'], $data['inbound_pop_user'], $data['inbound_pop_password'], $data['outbound_address'], $data['enable_outbound_for_inbound'], $data['enable_outbound_reply_link'], $data['outbound_from'], $data['enable_topic_smiley'], $data['enable_topic_summary'], $data['enable_ui_avatar'], $data['enable_ui_flag'], $data['enable_ui_posts'], $data['enable_ui_level'], $data['enable_ui_email'], $data['enable_ui_online'], $data['approval_type'], $data['moderator_group'], $data['forum_password'], $data['enable_password_protection'], $attConverter->convert($data['attachments']), $data['attachments_store'], $data['attachments_store_dir'], $data['attachments_max_size'], $data['forum_last_n'], $data['comments_per_page'], $data['thread_style'], $data['is_flat'], $data['list_att_nb'], $data['list_topic_last_post_title'], $data['list_topic_last_post_avatar'], $data['list_topic_author_avatar'], $data['forum_language']);
     return $id;
 }
Ejemplo n.º 18
0
 public function editCommentAction(Tags $tag, Comments $comment)
 {
     if ($this->request->isPost()) {
         $comment->update($this->request->getPost());
         return $this->success();
     }
     $this->view->mytag = $tag;
     $this->view->comment = $comment;
     $this->view->form = myForm::buildCommentForm($tag, $comment);
     //        dd($this->view->form);
 }
Ejemplo n.º 19
0
 public function actionComment()
 {
     $rows = Comments::model()->findAll();
     $model = new Comments();
     if (isset($_POST['Comments'])) {
         $model->attributes = $_POST['Comments'];
         if ($model->save()) {
             $this->redirect($this->createUrl('pages/comment'));
         }
     }
     $this->render('comment', array('rows' => $rows, 'model' => $model));
 }
Ejemplo n.º 20
0
 /**
  * Удалает комментарии о соискателе и его фото 
  *
  * @return void
  */
 public function _delete()
 {
     // Удаляем комменты о соискателе из БД
     $Comments = new Comments();
     $Comments->removeCommentsByApplicantId($this->id);
     // Удаляем фото
     $applicantId = $this->id;
     $validator = new Zend_Validate_File_Exists($_SERVER['DOCUMENT_ROOT'] . '/public/images/photos/');
     if ($validator->isValid($applicantId . '.jpg')) {
         unlink($_SERVER['DOCUMENT_ROOT'] . '/public/images/photos/' . $this->id . '.jpg');
     }
 }
Ejemplo n.º 21
0
 public function addComment($user_id, $post_id, $content)
 {
     $model = new Comments();
     $model->post_id = $post_id;
     $model->created_by = $user_id;
     $model->updated_at = time();
     $model->comment_content = $content;
     $model->status = 1;
     $model->created_at = time();
     $model->updated_at = time();
     $model->save(FALSE);
     $post = Posts::model()->findByPk($post_id);
     $post->post_comment_count++;
     $user = User::model()->findByPk($model->created_by);
     $user_commented = User::model()->findByPk($post->user_id);
     if ($user_commented) {
         if ($user->id != $post->user_id) {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by && $post->user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của {$user_commented->username}", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
             $arr_noti = array('user_id' => $user->id, 'content' => "{$user->username} vừa bình luận bài viết của bạn", 'type' => 'comment', 'recipient_id' => $user_commented->id, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
             Notifications::model()->add($arr_noti);
         } else {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của họ", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
         }
     }
     if ($model->save(FALSE) && $post->save(FALSE)) {
         $returnArr = array();
         $returnArr['created_by'] = $model->created_by;
         $returnArr['username'] = $user->username;
         $returnArr['photo'] = StringHelper::generateUrlImage($user->photo);
         $returnArr['created_at'] = Util::time_elapsed_string($model->created_at);
         $returnArr['comment_content'] = $model->comment_content;
         return $returnArr;
     }
     return FALSE;
 }
Ejemplo n.º 22
0
 public function getAllComments(mysqli $conn)
 {
     $sql = "SELECT * FROM Comments WHERE tweet_id = '" . $this->id . "'ORDER BY creation_date DESC";
     $result = $conn->query($sql);
     $retArray = array();
     if ($result->num_rows > 0) {
         while ($commentData = $result->fetch_assoc()) {
             $tempComment = new Comments();
             $tempComment->loadFromDB($conn, $commentData['id']);
             $retArray[] = $tempComment;
         }
     }
     return $retArray;
 }
Ejemplo n.º 23
0
 /**
  * Get comment by IRI
  * 
  * @param string $iri
  * @return Comment
  */
 protected function _getCommentByIri($iri)
 {
     $id = explode('_', $iri, 4);
     $source_id = @$id[0];
     $item_id = @$id[1];
     $comment_id = @$id[2];
     $item_type = @$id[3];
     // Gets the comment
     $comments = new Comments();
     foreach ($comments->getComments($source_id, $item_id) as $comment) {
         if ($comment['id'] == $comment_id) {
             return new Comment($comment);
         }
     }
 }
Ejemplo n.º 24
0
/**
 * listforum_pref: retrieve the list of forums for the home_forum preference
 *
 * @access public
 * @return array: forumId => name(truncated)
 */
function listforum_pref()
{
    include_once 'lib/comments/commentslib.php';
    $commentslib = new Comments();
    $allforums = $commentslib->list_forums(0, -1, 'name_desc', '');
    $listforums = array('' => 'None');
    if ($allforums['cant'] > 0) {
        foreach ($allforums['data'] as $oneforum) {
            $listforums[$oneforum['forumId']] = substr($oneforum['name'], 0, 30);
        }
    } else {
        $listforums[''] = tra('No forum available (create one first)');
    }
    return $listforums;
}
Ejemplo n.º 25
0
 /**
  *
  * @param unknown $sender
  * @param unknown $params
  */
 public function addComments($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->entityName) || ($entityName = trim($params->CallbackParameter->entityName)) === '') {
             throw new Exception('System Error: EntityName is not provided!');
         }
         if (!isset($params->CallbackParameter->entityId) || ($entityId = trim($params->CallbackParameter->entityId)) === '') {
             throw new Exception('System Error: entityId is not provided!');
         }
         if (!($entity = $entityName::get($entityId)) instanceof $entityName) {
             throw new Exception('System Error: no such a entity exisits!');
         }
         if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') {
             throw new Exception('System Error: invalid comments passed in!');
         }
         $comment = Comments::addComments($entity, $comments, Comments::TYPE_NORMAL);
         $results['item'] = $comment->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
 public function actionShowPosts($id, $mid, $sid)
 {
     $posts = Posts::model()->findByPk($sid);
     $multimedia = json_decode($posts->multimedia);
     $count = count($multimedia);
     foreach ($multimedia as $ind => $file) {
         if ($file->nomber == $mid) {
             $num = $ind + 1;
             if ($ind == 0) {
                 $prev = $multimedia[$count - 1]->nomber . '/' . $sid;
             } else {
                 $prev = $multimedia[$ind - 1]->nomber . '/' . $sid;
             }
             if ($ind == $count - 1) {
                 $next = $multimedia[0]->nomber . '/' . $sid;
             } else {
                 $next = $multimedia[$ind + 1]->nomber . '/' . $sid;
             }
             $current_photo = $file;
         }
     }
     $myPage = $id == Yii::app()->user->id;
     $myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
     $ext = Files::model()->findByPk($current_photo->id)->extension;
     $aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
     $comments = Comments::model()->getLast('posts_' . $sid, $mid, 10);
     $comments = array_reverse($comments);
     $file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date);
     $this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid));
 }
Ejemplo n.º 27
0
 /**
  * Handles get requests for the dashboard
  * @todo update check should probably be cron'd and cached, not re-checked every load
  */
 public function get_dashboard()
 {
     // Not sure how best to determine this yet, maybe set an option on install, maybe do this:
     $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
     $this->theme->active_time = HabariDateTime::date_create($firstpostdate);
     // get the active theme, so we can check it
     // @todo this should be worked into the main Update::check() code for registering beacons
     $active_theme = Themes::get_active();
     $active_theme = $active_theme->name . ':' . $active_theme->version;
     // check to see if we have updates to display
     $this->theme->updates = Options::get('updates_available', array());
     // collect all the stats we display on the dashboard
     $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
     $this->fetch_dashboard_modules();
     // check for first run
     $u = User::identify();
     if (!isset($u->info->experience_level)) {
         $this->theme->first_run = true;
         $u->info->experience_level = 'user';
         $u->info->commit();
     } else {
         $this->theme->first_run = false;
     }
     $this->display('dashboard');
 }
Ejemplo n.º 28
0
 /**
  * Recent Comments
  *
  * Handle recent comment block output
  *
  * @param Block $block The block instance to be configured
  * @param Theme $theme The active theme
  */
 public function action_block_content_recent_comments($block, $theme)
 {
     if (!($limit = $block->quantity)) {
         $limit = 5;
     }
     $offset = 0;
     $published_posts = 0;
     $valid_comments = array();
     // prevent endless looping if there are fewer comments than $limit
     $comments_remain = true;
     while ($published_posts < $limit && $comments_remain) {
         $comments = Comments::get(array('limit' => $limit - $published_posts, 'status' => Comment::STATUS_APPROVED, 'type' => Comment::COMMENT, 'offset' => $offset, 'orderby' => 'date DESC'));
         // check the posts
         foreach ($comments as $key => $comment) {
             if ($comment->post->status == Post::status('published')) {
                 $valid_comments[] = $comments[$key];
                 ++$published_posts;
             }
             ++$offset;
         }
         // stop looping if out of comments
         if (count($comments) === 0) {
             $comments_remain = false;
         }
     }
     $block->recent_comments = $valid_comments;
 }
Ejemplo n.º 29
0
 /**
  * list comments
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // url to view the comment
         $url = Comments::get_url($item['id']);
         // initialize variables
         $prefix = $label = $suffix = $icon = '';
         // the title as the label
         if ($item['create_name']) {
             $label .= ucfirst($item['create_name']) . ' ';
         }
         // time of creation
         $label .= Skin::build_date($item['create_date']);
         // text beginning
         if ($text = Skin::strip($item['description'], 10, NULL, NULL)) {
             $suffix = ' - ' . $text;
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'comment', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Ejemplo n.º 30
0
 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('home_tab', 'Home');
     //Set to whatever you want your first tab text to be.
     $this->assign('show_author', false);
     //Display author in posts
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     parent::add_template_vars();
     //from mzingi
     //visiting page/2, /3 will offset to the next page of posts in the sidebar
     $page = Controller::get_var('page');
     $pagination = Options::get('pagination');
     if ($page == '') {
         $page = 1;
     }
     $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
     //from mzingi
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
 }