public function actionSetMsg()
 {
     $data = Yii::$app->request->post();
     $phone = User::findOne(['phone' => $data['phone']]);
     $info = CollectInteract::findOne(['userid' => $phone['id'], 'msg' => $data['msg']]);
     if ($info) {
         echo json_encode(array('flag' => 0, 'msg' => 'Already collect!'));
         return;
     }
     $to = Message::findOne(['id' => $data['msg']]);
     $model2 = new Notify();
     $model2->from = $phone['id'];
     $model2->to = $to['userid'];
     $model2->message = '收藏';
     $model2->created_at = time();
     if (!$model2->save()) {
         echo json_encode(array('flag' => 0, 'msg' => 'Collect fail!'));
         return;
     }
     $model = new CollectInteract();
     $model->userid = $phone['id'];
     $model->msg = $data['msg'];
     $model->created_at = time();
     if ($model->save()) {
         echo json_encode(array('flag' => 1, 'msg' => 'Collect success!'));
     } else {
         echo json_encode(array('flag' => 0, 'msg' => 'Collect fail!'));
     }
 }
Example #2
0
 public function controller_global()
 {
     $this->cms();
     $this->contact_form = new WaxForm(new GetInTouch());
     if ($data = $this->contact_form->save()) {
         $notify = new Notify();
         $notify->send_contact_details($data->row);
         $this->redirect_to("/thanks/contact");
     }
 }
 /**
  * Function called when a Dolibarrr business event is done.
  * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
  *
  * @param string		$action		Event action code
  * @param Object		$object     Object
  * @param User		    $user       Object user
  * @param Translate 	$langs      Object langs
  * @param conf		    $conf       Object conf
  * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
 {
     if (empty($conf->notification->enabled)) {
         return 0;
     }
     // Module not active, we do nothing
     dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id);
     require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
     $notify = new Notify($this->db);
     $notify->send($action, $object);
     return 1;
 }
Example #4
0
 public function actionNotifications($id = 0, $action = '')
 {
     if ($id) {
         $notify = Notify::model()->findByPK($id);
         if (!$notify) {
             throw new CHttpException(404, Yii::t('errors', 'Wrong notify'));
         } elseif ($action) {
             if ($notify->status == 2 || $notify->status == 3) {
                 throw new CHttpException(404, Yii::t('errors', 'Status already set'));
             }
             if ($notify->shared_id) {
                 $cam = Shared::model()->findByPK($notify->shared_id);
                 if (!$cam) {
                     $notify->delete();
                     throw new CHttpException(404, Yii::t('errors', 'Wrong cam'));
                 }
             } else {
                 $notify->delete();
                 throw new CHttpException(404, Yii::t('errors', 'Wrong cam'));
             }
             $n = new Notify();
             $id = Yii::app()->user->getId();
             if ($action == 'approve') {
                 //TODO specify user and cam
                 $n->note(Yii::t('user', 'User approve shared cam'), array($id, $notify->creator_id, 0));
                 $cam->is_approved = 1;
                 $cam->save();
                 $notify->status = 2;
                 $notify->save();
             } elseif ($action == 'disapprove') {
                 $n->note(Yii::t('user', 'User decline shared cam'), array($id, $notify->creator_id, 0));
                 $cam->is_approved = 0;
                 $cam->save();
                 $notify->status = 3;
                 $notify->save();
             } else {
                 throw new CHttpException(404, Yii::t('errors', 'Wrong action'));
             }
         } else {
             throw new CHttpException(404, Yii::t('errors', 'Wrong action'));
         }
     }
     $new = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => 1));
     $old = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => array(0, 2, 3)), array('order' => 'time DESC'));
     foreach ($new as $notify) {
         if ($notify->shared_id == 0) {
             $notify->status = 0;
             $notify->save();
         }
     }
     $this->render('notify', array('new' => $new, 'old' => $old));
 }
Example #5
0
 public function addDigg($feedId, $uid)
 {
     $data["feedid"] = $feedId;
     $data["uid"] = $uid;
     $data["uid"] = !$data["uid"] ? Ibos::app()->user->uid : $data["uid"];
     if (!$data["uid"]) {
         $this->addError("addDigg", "未登录不能赞");
         return false;
     }
     $isExit = $this->getIsExists($feedId, $uid);
     if ($isExit) {
         $this->addError("addDigg", "你已经赞过");
         return false;
     }
     $data["ctime"] = time();
     $res = $this->add($data);
     if ($res) {
         $feed = Source::getSourceInfo("feed", $feedId);
         Feed::model()->updateCounters(array("diggcount" => 1), "feedid = " . $feedId);
         Feed::model()->cleanCache($feedId);
         $user = User::model()->fetchByUid($uid);
         $config["{user}"] = $user["realname"];
         $config["{sourceContent}"] = StringUtil::filterCleanHtml($feed["source_body"]);
         $config["{sourceContent}"] = str_replace("◆", "", $config["{sourceContent}"]);
         $config["{sourceContent}"] = StringUtil::cutStr($config["{sourceContent}"], 34);
         $config["{url}"] = $feed["source_url"];
         $config["{content}"] = Ibos::app()->getController()->renderPartial("application.modules.message.views.remindcontent", array("recentFeeds" => Feed::model()->getRecentFeeds()), true);
         Notify::model()->sendNotify($feed["uid"], "message_digg", $config);
         UserUtil::updateCreditByAction("diggweibo", $uid);
         UserUtil::updateCreditByAction("diggedweibo", $feed["uid"]);
     }
     return $res;
 }
Example #6
0
 function notify()
 {
     $order_id = $_GET['order_id'];
     $type = strtolower($_GET['type']);
     $type_arr = array('cancel', 'alert');
     if (!in_array($type, $type_arr)) {
         echo 'no_type';
         exit;
     }
     $order_model = M('Order');
     // 查找订单
     $order = $order_model->find($order_id);
     if (empty($order)) {
         echo 'no_order';
         exit;
     }
     if ($order['status'] > 1) {
         echo 'type_error';
         exit;
     }
     // 更改订单状态
     if ($type == 'cancel') {
         $order_model->setStatus($order['store_id'], $order['order_id'], 5);
         echo 'ok';
         exit;
     }
     if ($type == 'alert') {
         import('source.class.Notify');
         Notify::alert('尊敬的会员' . $order['address_user'] . '您好,您的订单号:' . $order_id . '未付款,请及时付款');
     }
 }
function do_private_post($content, $results)
{
    global $config, $speak;
    $results = Mecha::O($results);
    $results = $config->is->post ? Get::postHeader($results->path, POST . DS . $config->page_type, '/', $config->page_type . ':') : false;
    if ($results === false) {
        return $speak->plugin_private_post->description;
    }
    $s = isset($results->fields->pass) ? $results->fields->pass : "";
    if (strpos($s, ':') !== false) {
        $s = explode(':', $s, 2);
        if (isset($s[1])) {
            $speak->plugin_private_post->hint = ltrim($s[1]);
        }
        // override password hint
        $s = $s[0];
    }
    $hash = md5($s . PRIVATE_POST_SALT);
    $html = Notify::read(false) . '<div class="overlay--' . File::B(__DIR__) . '"></div><form class="form--' . File::B(__DIR__) . '" action="' . $config->url . '/' . File::B(__DIR__) . '/do:access" method="post">' . NL;
    $html .= TAB . Form::hidden('token', Guardian::token()) . NL;
    $html .= TAB . Form::hidden('_', $hash) . NL;
    $html .= TAB . Form::hidden('kick', $config->url_current) . NL;
    $html .= TAB . '<p>' . $speak->plugin_private_post->hint . '</p>' . NL;
    $html .= TAB . '<p>' . Form::text('access', "", $speak->password . '&hellip;', array('autocomplete' => 'off')) . ' ' . Form::button($speak->submit, null, 'submit') . '</p>' . NL;
    $html .= '</form>' . O_END;
    if ($results && isset($results->fields->pass) && trim($results->fields->pass) !== "") {
        if (!Guardian::happy() && Session::get('is_allow_post_access') !== $hash) {
            return $html;
        }
    }
    return $content;
}
Example #8
0
 public function setFocus($setFocus, $runId, $uid)
 {
     $run = $this->fetchByPk(intval($runId));
     $focusUser = $run["focususer"];
     if ($setFocus) {
         if (StringUtil::findIn($focusUser, $uid)) {
             return false;
         } else {
             $focusUser = array_unique(array_merge(array($uid), !empty($focusUser) ? explode(",", $focusUser) : array()));
             $allUser = FlowRunProcess::model()->fetchAllUidByRunId($runId);
             if (!empty($allUser)) {
                 $config = array("{runName}" => $run["name"], "{userName}" => User::model()->fetchRealNameByUid($uid));
                 Notify::model()->sendNotify($allUser, "workflow_focus_notice", $config);
             }
         }
     } elseif (!StringUtil::findIn($focusUser, $uid)) {
         return false;
     } else {
         $userPart = explode(",", $focusUser);
         $index = array_search($uid, $userPart);
         if (is_int($index)) {
             unset($userPart[$index]);
         }
         $focusUser = $userPart;
     }
     return $this->modify($runId, array("focususer" => implode(",", $focusUser)));
 }
Example #9
0
 public static function instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #10
0
 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return	void
  * @since	1.6
  */
 function featured()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Initialise variables.
     $ids = Request::getVar('cid', array(), '', 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = \Hubzero\Utility\Arr::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             Notify::warning(Lang::txt('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         Notify::error(Lang::txt('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             throw new Exception($model->getError(), 500);
         }
     }
     $this->setRedirect('index.php?option=com_content&view=articles');
 }
Example #11
0
 public function actionSetup()
 {
     $formSubmit = EnvUtil::submitCheck("formhash");
     if ($formSubmit) {
         $data =& $_POST;
         foreach (array("sendemail", "sendsms", "sendmessage") as $field) {
             if (!empty($data[$field])) {
                 $ids = array_keys($data[$field]);
                 $idstr = implode(",", $ids);
                 Notify::model()->updateAll(array($field => 1), sprintf("FIND_IN_SET(id,'%s')", $idstr));
                 Notify::model()->updateAll(array($field => 0), sprintf("NOT FIND_IN_SET(id,'%s')", $idstr));
             } else {
                 Notify::model()->updateAll(array($field => 0));
             }
         }
         CacheUtil::update("NotifyNode");
         $this->success(Ibos::lang("Save succeed", "message"));
     } else {
         $nodeList = Notify::model()->getNodeList();
         foreach ($nodeList as &$node) {
             $node["moduleName"] = Module::model()->fetchNameByModule($node["module"]);
         }
         $this->render("setup", array("nodeList" => $nodeList));
     }
 }
Example #12
0
 /**
  * Removes an item
  */
 function delete()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Initialise variables.
     $ids = Request::getVar('cid', array(), '', 'array');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!User::authorise('core.delete', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't delete.
             unset($ids[$i]);
             Notify::warning(Lang::txt('JERROR_CORE_DELETE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         Notify::error(Lang::txt('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Remove the items.
         if (!$model->featured($ids, 0)) {
             throw new Exception($model->getError(), 500);
         }
     }
     $this->setRedirect('index.php?option=com_content&view=featured');
 }
Example #13
0
 public function sms($params)
 {
     $module = $params['module'];
     $url = "";
     if ($params['params']) {
         $url = $this->OAuth2Url($this->buildUrl($params), $this->_base_config['APP']['sms']['agentid']);
     }
     $postData = array();
     switch ($params['module']) {
         case "email":
             $content = $url != "" ? $params['content'] . ("\n<a href='" . $url . "'>") . _("ÔĶÁÓʼþ") . "</a>" : $params['content'];
             $postData = array("touser" => $this->cUser($params['user']), "toparty" => $this->cDept($params['dept']), "msgtype" => "text", "agentid" => $this->_base_config['APP']['sms']['agentid'], "text" => array("content" => $content), "safe" => "0");
             break;
         case "news":
             $picurl = "";
             include_once "oa.news.php";
             //( );
             $News = new News();
             $row = $News->getById("SUBJECT,CONTENT,ATTACHMENT_ID,ATTACHMENT_NAME,TO_ID,USER_ID,SUMMARY", $params['params']);
             $picurl = $News->getFirstImage("news", $row['ATTACHMENT_ID'], $row['ATTACHMENT_NAME']);
             $description = $row['SUMMARY'] == "" ? csubstr(strip_tags($this->cContent($row['CONTENT'])), 0, 30, TRUE, 1) . "..." : strip_tags($this->cContent($row['SUMMARY']));
             if ($picurl != "") {
                 $picurl = $this->buildAttachUrl("http://" . BASE_URL . $picurl, $this->_base_config['APP']['sms']['agentid']);
             }
             $postData = array("touser" => $this->cUser($row['USER_ID'], $row['TO_ID']), "toparty" => $row['TO_ID'] == "ALL_DEPT" ? "" : $this->cDept($row['TO_ID']), "msgtype" => "news", "agentid" => $this->_base_config['APP']['sms']['agentid'], "news" => array("articles" => array(array("title" => strip_tags($row['SUBJECT']), "description" => $description, "url" => $url, "picurl" => $picurl))));
             //parent::logs("test",$url);
             break;
         case "notify":
             $picurl = "";
             include_once "oa.notify.php";
             //( );
             $Notify = new Notify();
             $row = $Notify->getById("SUBJECT,CONTENT,ATTACHMENT_ID,ATTACHMENT_NAME,TO_ID,USER_ID,SUMMARY", $params['params']);
             $picurl = $Notify->getFirstImage("notify", $row['ATTACHMENT_ID'], $row['ATTACHMENT_NAME']);
             $description = $row['SUMMARY'] == "" ? csubstr(strip_tags($this->cContent($row['CONTENT'])), 0, 30, TRUE, 1) . "..." : strip_tags($this->cContent($row['SUMMARY']));
             if ($picurl != "") {
                 $picurl = $this->buildAttachUrl("http://" . BASE_URL . $picurl, $this->_base_config['APP']['sms']['agentid']);
             }
             $postData = array("touser" => $this->cUser($row['USER_ID'], $row['TO_ID']), "toparty" => $row['TO_ID'] == "ALL_DEPT" ? "" : $this->cDept($row['TO_ID']), "msgtype" => "news", "agentid" => $this->_base_config['APP']['sms']['agentid'], "news" => array("articles" => array(array("title" => strip_tags($row['SUBJECT']), "description" => $description, "url" => $url, "picurl" => $picurl))));
             //parent::logs("test",$url);
             break;
         default:
             $postData = array("touser" => $this->cUser($params['user']), "toparty" => $this->cDept($params['dept']), "msgtype" => "text", "agentid" => $this->_base_config['APP']['sms']['agentid'], "text" => array("content" => $params['content']), "safe" => "0");
     }
     $rs = $this->postData($this->url['send'], $postData);
 }
 public function readNotify($array)
 {
     $criteria = new CDbCriteria();
     foreach ($array as $id) {
         $criteria->addCondition('id=' . (int) $id, 'OR');
     }
     Notify::model()->updateAll(array('read' => Notify::READ), $criteria);
 }
 function ProcessRequest()
 {
     $objNotify = new Notify();
     if (isset($_GET['notifId'])) {
         $arrModule = $objNotify->GetModuleFromNotify($_GET['notifId']);
         $urlRedirect = Dispatcher::Instance()->GetUrl($arrModule['module'], $arrModule['submodule'], $arrModule['action'], $arrModule['type']) . $arrModule['notifyUrl'];
         return array('exec' => 'GtfwAjax.replaceContentWithUrl("subcontent-element","' . $urlRedirect . '&ascomponent=1")');
     }
     if (isset($_GET['readNotifyId'])) {
         $objNotify->setReadNotify($_GET['readNotifyId']);
     }
     if (isset($_GET['statusMessage'])) {
         $message = $objNotify->GetAllNotify();
     } else {
         $message = $objNotify->GetUnloadNotify();
     }
     return array("exec" => "setNotify(" . json_encode($message) . ")");
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $lesson = Lesson::create(Input::all());
     // Alternatively, fire and listen for an event
     // Then, call this from the listener.
     Notify::lessonSubscribers($lesson);
     return 'Success';
     // or redirect or whatever
 }
Example #17
0
 /**
  * Create a new member
  *
  * @return     void
  */
 public function addTask()
 {
     Request::setVar('hidemainmenu', 1);
     // Set any errors
     foreach ($this->getErrors() as $error) {
         \Notify::error($error);
     }
     // Output the HTML
     $this->view->setLayout('add')->display();
 }
Example #18
0
 /**
  * Default Shortcut Variable(s)
  * ----------------------------
  */
 public static function cargo()
 {
     $config = Config::get();
     $token = Guardian::token();
     $results = array('config' => $config, 'speak' => $config->speak, 'articles' => $config->articles, 'article' => $config->article, 'pages' => $config->pages, 'page' => $config->page, 'pager' => $config->pagination, 'manager' => Guardian::happy(), 'token' => $token, 'messages' => Notify::read(false), 'message' => Notify::read(false));
     Session::set(Guardian::$token, $token);
     unset($config, $token);
     self::$lot = array_merge(self::$lot, $results);
     return self::$lot;
 }
Example #19
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->requiresPjax()) {
         echo Notify::widget($this->notifyOptions);
     }
     $id = $this->options['id'];
     if ($this->modal) {
         $this->getView()->registerJs("Admin.Modal.pjax('#{$id}');");
     }
     parent::run();
 }
Example #20
0
 public function send($bodyId, $bodyData, $inboxId = EmailBaseController::INBOX_ID)
 {
     $toids = $bodyData["toids"] . "," . $bodyData["copytoids"] . "," . $bodyData["secrettoids"];
     $toid = StringUtil::filterStr($toids);
     foreach (explode(",", $toid) as $uid) {
         $email = array("toid" => $uid, "fid" => $inboxId, "bodyid" => $bodyId);
         $newId = $this->add($email, true);
         $config = array("{sender}" => Ibos::app()->user->realname, "{subject}" => $bodyData["subject"], "{url}" => Ibos::app()->urlManager->createUrl("email/content/show", array("id" => $newId)), "{content}" => Ibos::app()->getController()->renderPartial("application.modules.email.views.remindcontent", array("body" => $bodyData), true));
         Notify::model()->sendNotify($uid, "email_message", $config);
     }
 }
Example #21
0
 /**
  * @covers NativeURI::getSegment
  * @depends testGetCurrentUrl
  */
 public function testGetSegment($data)
 {
     $url = $data['url'];
     $index0 = 0;
     $expected = 'localhost';
     $actual = $this->object->getSegment($index0, $url);
     $this->assertEquals($expected, $actual);
     $index1 = 1;
     $expected = 'NotifyNativeDemo';
     $actual = $this->object->getSegment($index1, $url);
     $this->assertEquals($expected, $actual);
 }
Example #22
0
 /**
  * check if still signned in
  *
  * @param array $request_data POST array
  * @return bool
  *
  * @url POST
  * @access public
  */
 function post($request_data = NULL)
 {
     $return = array();
     // validate and sanitize
     /*$this->filter->set_request_data($request_data);
     		$this->filter->set_group_rules('contact');
     		$this->filter->set_key_rules(array('email', 'message'), 'required');
     		if(!$this->filter->run()) {
     			$return["errors"] = $this->filter->get_errors('error');
     			return $return;
     		}
     		$request_data = $this->filter->get_request_data();*/
     $request_data = $this->filter->run($request_data);
     if ($this->filter->hasErrors()) {
         return $this->filter->getErrorsReturn();
     }
     $request_data['name'] = isset($request_data['name']) ? $request_data['name'] : '';
     $notify = new Notify();
     $notify->emailHome('Support/Contact', 'Name:' . $request_data['name'] . '\\n' . 'From:' . $request_data['email'] . '\\n' . $request_data['message']);
     return TRUE;
 }
Example #23
0
 public function before()
 {
     //$this->redirect('http://ehistory.kz/manage');
     parent::before();
     $this->response->headers('cache-control', 'private');
     // creating and attaching page metadata
     $this->metadata = new Model_Metadata();
     $this->metadata->title(__(Application::instance()->get('title')), false);
     $this->set('_metadata', $this->metadata);
     Auth::instance()->auto_login();
     if (!Auth::instance()->logged_in()) {
         $this->redirect('manage/auth/login');
     } else {
         $id = Auth::instance()->get_user()->id;
         $user = ORM::factory('user', $id);
         $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))) || $user->has('roles', ORM::factory('Role', array('name' => 'moderator')));
         $input_redactor = $user->has('roles', ORM::factory('Role', array('name' => 'redactor')));
         if (!$input && !$input_redactor) {
             $this->redirect('/manage/auth/logout');
         }
         if (!$input && (strtolower($this->request->controller()) != 'ehistory' && strtolower($this->request->controller()) != 'language')) {
             $this->redirect('manage/ehistory');
         }
     }
     $this->user = Auth::instance()->get_user();
     if (Request::$initial === Request::$current) {
         $messages = Notify::instance()->get_all_once();
         $this->set('_notifications', $messages);
     }
     $language = Session::instance()->get('_language', 'ru');
     $this->language = in_array($language, array('ru', 'en', 'kz')) ? $language : 'ru';
     I18n::lang($this->language);
     $rr = Request::initial()->uri() . urlencode(URL::query(null, true));
     $rr = trim($rr, '/');
     //$this->metadata->title('Sharua.kz', false);
     $countcomm = ORM::factory('Comment')->where('status', '=', '0')->count_all();
     //смотрим сколько новых коментов
     $this->set('_user', $this->user)->set('_language', $this->language)->set('_return_url', $rr)->set('_countcomm', $countcomm);
     //вносим в переменную количество новых коментов
     $knigi = ORM::factory('Book')->where('category_id', '=', '0')->find_all();
     //смотрим сколько книг без категории
     if ($knigi) {
         if (count($knigi) > 0) {
             $this->set('_uncatcount', count($knigi));
             //вносим в переменную количество книг без категории
         }
     }
     $this->referrer = Request::initial()->referrer();
     if (Message::get()) {
         $this->set('basic_message', Message::display('/message/basic'));
     }
 }
 public function run()
 {
     $model = [];
     $count_new = 0;
     if (!Yii::app()->user->isGuest) {
         $count_new = Notify::getCountNew();
         $model = Notify::getNotify(null, null, $count_new);
     } elseif (Yii::app()->notify->isShowForGuest) {
         //unset(Yii::app()->notify->guestSession);
         $session = Yii::app()->notify->guestSession;
         if (!isset($session['id'])) {
             $session = ['id' => 'guest_' . rand()];
             Yii::app()->notify->guestSession = $session;
         }
         $count_new = 1;
         /*if(empty($session['status']))
               $count_new = 1;
           else
               $count_new = 0;*/
         $newModel = new Notify();
         $newModel->id = $session['id'];
         //            $newModel->header = 'Hello, welcome back!';
         $newModel->description = Yii::app()->notify->messageForGuest;
         //            $newModel->date_show = date("Y-m-d H:i:s");
         $newModel->setUrl(['/site/login']);
         $newModel->img = $newModel->getDefaultImage();
         $model = [$newModel];
     }
     if (Yii::app()->user->isGuest) {
         $isShowForGuest = Yii::app()->notify->isShowForGuest && empty(Yii::app()->notify->guestSession['status']) ? true : false;
         $isCheckNew = false;
     } else {
         $isShowForGuest = false;
         $isCheckNew = true;
     }
     $this->render('widget', array('model' => $model, 'count_new' => $count_new, 'assetsPath' => $this->module->publishedUrl, 'timeUpdateCenter' => Yii::app()->notify->timeUpdateCenter, 'notifyUrlUpdate' => $this->module->notifyUrlUpdate, 'isCheckNew' => $isCheckNew, 'isShowForGuest' => $isShowForGuest));
 }
Example #25
0
function notify_controller()
{
    global $route, $session, $mysqli;
    $result = false;
    include "Modules/notify/notify_model.php";
    $notify = new Notify($mysqli);
    if ($route->format == 'html') {
        if ($session['write']) {
            $result = view("Modules/notify/notify_view.php", array());
        }
    }
    if ($route->format == 'json') {
        if ($session['write'] && $route->action == 'status') {
            $result = $notify->status($session['userid']);
        }
        if ($session['write'] && $route->action == 'enable') {
            $result = $notify->enable($session['userid'], get('email'));
        }
        if ($session['write'] && $route->action == 'disable') {
            $result = $notify->disable($session['userid']);
        }
    }
    return array('content' => $result);
}
Example #26
0
 function addComment()
 {
     global $current_user;
     $subscribe = false;
     if (isset(Request::$post['subscribe'])) {
         if (Request::$post['subscribe']) {
             $subscribe = true;
         }
     }
     if (!$current_user->id) {
         return;
     }
     $comment = isset(Request::$post['comment']) ? Request::$post['comment'] : false;
     $comment = trim(prepare_review($comment, '<em><i><strong><b><u><s>'));
     if (!$comment) {
         throw new Exception('comment body expected');
     }
     $post_id = Request::$post['id'];
     $data = array();
     if ($post_id) {
         if (isset(Request::$post['comment_id']) && ($comment_id = Request::$post['comment_id'])) {
             $data = MongoDatabase::addEventComment($post_id, $current_user->id, $comment, $comment_id);
             if ($data) {
                 Notify::notifyEventCommentAnswer($data['commenter_id'], $post_id, $data['comment_id']);
             }
         } else {
             $data = MongoDatabase::addEventComment($post_id, $current_user->id, $comment);
             if ($data) {
                 Notify::notifyEventComment($data['user_id'], $post_id, $data['comment_id']);
             }
         }
     }
     if ($data) {
         if ($subscribe) {
             // на своё и так и так подписаны
             if ($data['post']['user_id'] != $current_user->id) {
                 $query = 'SELECT `id` FROM `events` WHERE `mongoid`=' . Database::escape($post_id);
                 $intid = Database::sql2single($query);
                 if ($intid) {
                     /* @var $current_user User */
                     $current_user->setNotifyRule(UserNotify::UN_COMMENT_ANSWER, UserNotify::UNT_NOTIFY);
                     $current_user->save();
                     Notify::notifySubscribe($current_user->id, $intid);
                 }
             }
         }
     }
 }
Example #27
0
 public function addComment($data, $forApi = false, $notCount = false, $lessUids = null)
 {
     $add = $this->escapeData($data);
     if ($add["content"] === "") {
         $this->addError("comment", Ibos::lang("Required comment content", "message.default"));
         return false;
     }
     $add["isdel"] = 0;
     $res = $this->add($add, true);
     if ($res) {
         isset($data["touid"]) && !empty($data["touid"]) && ($lessUids[] = intval($data["touid"]));
         $scream = explode("//", $data["content"]);
         Atme::model()->addAtme("message", "comment", trim($scream[0]), $res, null, $lessUids);
         $table = ucfirst($add["table"]);
         $pk = $table::model()->getTableSchema()->primaryKey;
         $table::model()->updateCounters(array("commentcount" => 1), "`{$pk}` = {$add["rowid"]}");
         if (Ibos::app()->user->uid != $add["moduleuid"] && $add["moduleuid"] != "") {
             !$notCount && UserData::model()->updateKey("unread_comment", 1, true, $add["moduleuid"]);
         }
         if (!empty($add["touid"]) && $add["touid"] != Ibos::app()->user->uid && $add["touid"] != $add["moduleuid"]) {
             !$notCount && UserData::model()->updateKey("unread_comment", 1, true, $add["touid"]);
         }
         if ($add["table"] == "feed") {
             if (Ibos::app()->user->uid != $add["uid"]) {
                 UserUtil::updateCreditByAction("addcomment", Ibos::app()->user->uid);
                 UserUtil::updateCreditByAction("getcomment", $data["moduleuid"]);
             }
             Feed::model()->cleanCache($add["rowid"]);
         }
         if ($add["touid"] != Ibos::app()->user->uid || $add["moduleuid"] != Ibos::app()->user->uid && $add["moduleuid"] != "") {
             $author = User::model()->fetchByUid(Ibos::app()->user->uid);
             $config["{name}"] = $author["realname"];
             $sourceInfo = Source::getCommentSource($add, $forApi);
             $config["{url}"] = $sourceInfo["source_url"];
             $config["{sourceContent}"] = StringUtil::parseHtml($sourceInfo["source_content"]);
             if (!empty($add["touid"])) {
                 $config["{commentType}"] = "回复了我的评论:";
                 Notify::model()->sendNotify($add["touid"], "comment", $config);
             } else {
                 $config["{commentType}"] = "评论了我的微博:";
                 if (!empty($add["moduleuid"])) {
                     Notify::model()->sendNotify($add["moduleuid"], "comment", $config);
                 }
             }
         }
     }
     return $res;
 }
Example #28
0
 /**
  * Don't allow categories to be deleted if they contain items or subcategories with items
  *
  * @param   string   $context  The context for the content passed to the plugin.
  * @param   object   $data     The data relating to the content that was deleted.
  * @return  boolean
  */
 public function onContentBeforeDelete($context, $data)
 {
     // Skip plugin if we are deleting something other than categories
     if ($context != 'com_categories.category') {
         return true;
     }
     // Check if this function is enabled.
     if (!$this->params->def('check_categories', 1)) {
         return true;
     }
     $extension = Request::getString('extension');
     // Default to true if not a core extension
     $result = true;
     $tableInfo = array('com_content' => array('table_name' => '#__content'), 'com_newsfeeds' => array('table_name' => '#__newsfeeds'));
     // Now check to see if this is a known core extension
     if (isset($tableInfo[$extension])) {
         // Get table name for known core extensions
         $table = $tableInfo[$extension]['table_name'];
         // See if this category has any content items
         $count = $this->_countItemsInCategory($table, $data->get('id'));
         // Return false if db error
         if ($count === false) {
             $result = false;
         } else {
             // Show error if items are found in the category
             if ($count > 0) {
                 $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
                 Notify::warning(403, $msg);
                 $result = false;
             }
             // Check for items in any child categories (if it is a leaf, there are no child categories)
             if (!$data->isLeaf()) {
                 $count = $this->_countItemsInChildren($table, $data->get('id'), $data);
                 if ($count === false) {
                     $result = false;
                 } elseif ($count > 0) {
                     $msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
                     Notify::warning(403, $msg);
                     $result = false;
                 }
             }
         }
         return $result;
     }
 }
Example #29
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->preview = Component::params('com_templates')->get('template_positions_display');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         App::abort(500, implode("\n", $errors));
         return false;
     }
     // Check if there are no matching items
     if (!count($this->items)) {
         Notify::warning(Lang::txt('COM_TEMPLATES_MSG_MANAGE_NO_STYLES'));
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Example #30
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors), 500, E_ERROR);
         return false;
     }
     // Check if there are no matching items
     if (!count($this->items)) {
         Notify::warning(Lang::txt('COM_MODULES_MSG_MANAGE_NO_MODULES'));
     }
     $this->addToolbar();
     // Include the component HTML helpers.
     Html::addIncludePath(JPATH_COMPONENT . '/helpers/html');
     parent::display($tpl);
 }