示例#1
0
 public function login()
 {
     RoutingEngine::setPage("runnDAILY Login", "PV__400");
     if (RoutingEngine::getInstance()->requirePermission("PV__300")) {
         Notification::add("You are already logged in.");
         Page::redirect("/");
     }
 }
示例#2
0
文件: T.php 项目: ph7pal/mei
 public function addNotice($replytouid, $logid, $info, $type = 'comment')
 {
     $data = array('uid' => $replytouid, 'content' => $info, 'new' => 1, 'type' => $type, 'cTime' => time(), 'from_id' => $logid, 'from_num' => 1);
     if (Notification::add($data)) {
         return true;
     } else {
         return false;
     }
 }
示例#3
0
 public function action_elevation_add_packed()
 {
     if ($_FILES["packed_hdr"]) {
         move_uploaded_file($_FILES["packed_hdr"]["tmp_name"], SYSTEM_ROOT . "/elev_packed.hdr");
     }
     if ($_FILES["packed_flt"]) {
         move_uploaded_file($_FILES["packed_flt"]["tmp_name"], SYSTEM_ROOT . "/elev_packed.flt");
     }
     $region = array_safe($_POST, "region_name", "Elevation data");
     Elevation::addElevationToDatabase(SYSTEM_ROOT . "/elev_packed", 1, $region);
     unlink(SYSTEM_ROOT . "/elev_packed.hdr");
     unlink(SYSTEM_ROOT . "/elev_packed.flt");
     Notification::add("Elevation data has been added");
     Page::redirect("/admin/elevation");
 }
示例#4
0
 function delete()
 {
     //check permissions
     if (!isset($_POST["e_eid"])) {
         Notification::add("Could not delete the event.");
         Page::redirect("/events");
     }
     $event = new Event($_POST);
     if ($event->delete()) {
         Notification::add("Event was deleted.");
         Page::redirect("/events");
     }
     Notification::add("Error deleting.");
     Page::redirect("/events");
 }
示例#5
0
 /**
  * Install mreporting notifications.
  * 
  * @return array 'success' => true on success
  */
 static function install()
 {
     global $LANG, $DB;
     // Création du template de la notification
     $template = new NotificationTemplate();
     $found_template = $template->find("itemtype = 'PluginMreportingNotification'");
     if (count($found_template) == 0) {
         $template_id = $template->add(array('name' => $LANG['plugin_mreporting']['notification_name'], 'comment' => $LANG['plugin_mreporting']['notification_comment'], 'itemtype' => 'PluginMreportingNotification'));
         // Ajout d'une traduction (texte) en Français
         $translation = new NotificationTemplateTranslation();
         $translation->add(array('notificationtemplates_id' => $template_id, 'language' => '', 'subject' => $LANG['plugin_mreporting']['notification_subject'], 'content_text' => $LANG['plugin_mreporting']['notification_text'], 'content_html' => $LANG['plugin_mreporting']['notification_html']));
         // Création de la notification
         $notification = new Notification();
         $notification_id = $notification->add(array('name' => $LANG['plugin_mreporting']['notification_name'], 'comment' => $LANG['plugin_mreporting']['notification_comment'], 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'itemtype' => 'PluginMreportingNotification', 'notificationtemplates_id' => $template_id, 'event' => 'sendReporting', 'mode' => 'mail'));
     }
     $DB->query('INSERT INTO glpi_notificationtargets (items_id, type, notifications_id) 
            VALUES (1, 1, ' . $notification_id . ');');
     return array('success' => true);
 }
 public static function install()
 {
     $notifications = array('plugin_formcreator_form_created' => array('name' => __('A form has been created', 'formcreator'), 'subject' => __('Your request have been saved', 'formcreator'), 'content' => __('Hi,\\nYour request from GLPI have been successfully saved with number ##formcreator.request_id## and transmetted to the helpdesk team.\\nYou can see your answers onto the following link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_need_validation' => array('name' => __('A form need to be validate', 'formcreator'), 'subject' => __('A form from GLPI need to be validate', 'formcreator'), 'content' => __('Hi,\\nA form from GLPI need to be validate and you have been choosen as the validator.\\nYou can access it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::APPROVER), 'plugin_formcreator_refused' => array('name' => __('The form is refused', 'formcreator'), 'subject' => __('Your form have been refused by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your form have been refused by the validator for the reason below:\\n##formcreator.validation_comment##\\n\\nYou can still modify and resubmit it by clicking onto this link:\\n##formcreator.validation_link##', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_accepted' => array('name' => __('The form is accepted', 'formcreator'), 'subject' => __('Your form have been accepted by the validator', 'formcreator'), 'content' => __('Hi,\\nWe are pleased to inform you that your form have been accepted by the validator.\\nYour request will be considered soon.', 'formcreator'), 'notified' => self::AUTHOR), 'plugin_formcreator_deleted' => array('name' => __('The form is deleted', 'formcreator'), 'subject' => __('Your form have been deleted by an administrator', 'formcreator'), 'content' => __('Hi,\\nWe are sorry to inform you that your request cannot be considered and have been deleted by an administrator.', 'formcreator'), 'notified' => self::AUTHOR));
     // Create the notification template
     $notification = new Notification();
     $notification_target = new NotificationTarget();
     $template = new NotificationTemplate();
     $translation = new NotificationTemplateTranslation();
     foreach ($notifications as $event => $datas) {
         // Check if notification allready exists
         $exists = $notification->find("itemtype = 'PluginFormcreatorFormanswer' AND event = '{$event}'");
         // If it doesn't exists, create it
         if (count($exists) == 0) {
             $template_id = $template->add(array('name' => addslashes($datas['name']), 'comment' => '', 'itemtype' => 'PluginFormcreatorFormanswer'));
             // Add a default translation for the template
             $translation->add(array('notificationtemplates_id' => $template_id, 'language' => '', 'subject' => addslashes($datas['subject']), 'content_text' => addslashes($datas['content']), 'content_html' => '<p>' . str_replace('\\n', '<br />', $datas['content']) . '</p>'));
             // Create the notification
             $notification_id = $notification->add(array('name' => addslashes($datas['name']), 'comment' => '', 'entities_id' => 0, 'is_recursive' => 1, 'is_active' => 1, 'itemtype' => 'PluginFormcreatorFormanswer', 'notificationtemplates_id' => $template_id, 'event' => $event, 'mode' => 'mail'));
             // Add default notification targets
             $notification_target->add(array("items_id" => $datas['notified'], "type" => Notification::USER_TYPE, "notifications_id" => $notification_id));
         }
     }
 }
 public function merge($ids)
 {
     // get the first sequence
     $firstID = array_pop($ids);
     $sequence = LevelUp::find($firstID);
     // Check the sequences are the same
     foreach ($ids as $id) {
         $oldSeq = LevelUp::find($id);
         foreach ($oldSeq->data as $data) {
             $newData = $sequence->data->where('level', $data->level)->first();
             if ($newData) {
                 if ($newData->fish !== $data->fish || $newData->wood !== $data->wood || $newData->iron !== $data->iron || $newData->time !== $data->time) {
                     \Notification::add('warning', 'Sequences are different at level ' . $newData->level . '!');
                     return false;
                 }
             }
         }
     }
     foreach ($ids as $id) {
         // then reattach the other dragons to this sequence
         foreach ($oldSeq->dragons as $dragon) {
             $dragon->levelUp()->associate($sequence);
             $dragon->save();
         }
         // Copy data across or delete the data
         foreach ($oldSeq->data as $data) {
             $newData = $sequence->data->where('level', $data->level)->first();
             if (!$newData) {
                 $sequence->data()->save($data);
             } else {
                 $data->delete();
             }
         }
         // and delete the sequence
         $oldSeq->delete();
     }
 }
示例#8
0
文件: Posts.php 项目: ph7pal/momo
 public static function favorite($code, $type, $from = 'web', $uid = '')
 {
     if (!$code || !$type) {
         return array('status' => 0, 'msg' => '数据不全,请核实');
     }
     if (!in_array($type, array('post'))) {
         return array('status' => 0, 'msg' => '暂不允许的分类');
     }
     if (is_numeric($code)) {
         $id = $code;
     } else {
         $codeArr = Posts::decode($code);
         if ($codeArr['type'] != $type || !is_numeric($codeArr['id']) || $codeArr['id'] < 1) {
             $this->jsonOutPut(0, '您所查看的内容不存在');
         }
         $id = $codeArr['id'];
     }
     if (!$uid) {
         $uid = zmf::uid();
     }
     if ($uid) {
         if (zmf::actionLimit('favorite-' . $type, $id)) {
             return array('status' => 0, 'msg' => '操作太频繁,请稍后再试');
         }
     } else {
         //没有登录的访客点收藏时判断是否已收藏过
         if (zmf::actionLimit('favorite-' . $type, $id, 1, 86400, true)) {
             return array('status' => 1, 'msg' => '已点赞', 'state' => 1);
         }
         $uid = 0;
     }
     $postInfo = Posts::model()->findByPk($id);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         return array('status' => 0, 'msg' => '文章不存在');
     }
     $attr = array('uid' => $uid, 'logid' => $id, 'classify' => $type);
     $info = false;
     if ($uid) {
         $info = Favorites::model()->findByAttributes($attr);
     }
     if ($info) {
         if (Favorites::model()->deleteByPk($info['id'])) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', -1, 'favorite');
             }
             return array('status' => 1, 'msg' => '取消点赞', 'state' => 3);
         } else {
             return array('status' => 0, 'msg' => '取消点赞失败', 'state' => 4);
         }
     } else {
         $attr['cTime'] = zmf::now();
         $model = new Favorites();
         $model->attributes = $attr;
         if ($model->save()) {
             if ($type == 'post') {
                 Posts::updateCount($id, 'Posts', 1, 'favorite');
             }
             //点赞后给对方发提醒
             $_noticedata = array('uid' => $postInfo['uid'], 'authorid' => $uid, 'content' => "您的文章【{$postInfo['title']}】有了新的赞", 'new' => 1, 'type' => 'favorite', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
             Notification::add($_noticedata);
             return array('status' => 1, 'msg' => '点赞成功', 'state' => 1);
         } else {
             return array('status' => 0, 'msg' => '点赞失败', 'state' => 2);
         }
     }
 }
 /**
  * Returns an Event specified by the provided proxy_id, content_type and record_id, as well
  * as a record_proxy_id in the case of some types of content. 
  * 
  * @param string $content_type
  * @param int $record_id
  * @param int $record_proxy_id
  * @return array
  */
 public static function addAllNotifications($content_type, $record_id, $record_proxy_id = 0, $proxy_id, $content_id)
 {
     global $db;
     $query = "SELECT * FROM `notification_users` \n\t\t\t\t\tWHERE `content_type` = " . $db->qstr($content_type) . "\n\t\t\t\t\tAND `notify_active` = 1\n\t\t\t\t\tAND `record_id` = " . $db->qstr($record_id) . ($record_proxy_id ? "\n\t\t\t\t\tAND `record_proxy_id` = " . $db->qstr($record_proxy_id) : "");
     $results = $db->getAll($query);
     if ($results) {
         require_once "Models/notifications/Notification.class.php";
         foreach ($results as $result) {
             if ($result["proxy_id"] != $proxy_id) {
                 $notification = Notification::add($result["nuser_id"], $proxy_id, $content_id);
             }
         }
     }
     return false;
 }
示例#10
0
 public function action_copy_view()
 {
     RoutingEngine::setPage("runnDAILY Routes", "PV__300");
     $route = new Route($_POST);
     if ($route->copy()) {
         Notification::add("Your route - {$route->name} - was copied.");
         Page::redirect("/routes/view/{$route->id}");
     }
     Notification::add("There was an error copying the route.  Try again.");
     Page::redirect("/routes/view/{$route->id}");
 }
示例#11
0
 public function afterCreate($image)
 {
     Notification::add($image->id, 'Image');
 }
    public static function install(Migration $migration)
    {
        global $DB;
        $migration->displayMessage("Migrate PluginOrderOrder notifications");
        $template = new NotificationTemplate();
        $templates_id = false;
        $query_id = "SELECT `id`\n                       FROM `glpi_notificationtemplates`\n                       WHERE `itemtype`='PluginOrderOrder'\n                       AND `name` = 'Order Validation'";
        $result = $DB->query($query_id) or die($DB->error());
        if ($DB->numrows($result) > 0) {
            $templates_id = $DB->result($result, 0, 'id');
        } else {
            $tmp = array('name' => 'Order Validation', 'itemtype' => 'PluginOrderOrder', 'date_mod' => $_SESSION['glpi_currenttime'], 'comment' => '', 'css' => '');
            $templates_id = $template->add($tmp);
        }
        if ($templates_id) {
            $translation = new NotificationTemplateTranslation();
            if (!countElementsInTable($translation->getTable(), "`notificationtemplates_id`='{$templates_id}'")) {
                $tmp['notificationtemplates_id'] = $templates_id;
                $tmp['language'] = '';
                $tmp['subject'] = '##lang.ordervalidation.title##';
                $tmp['content_text'] = '##lang.ordervalidation.url## : ##ordervalidation.url##
               ##lang.ordervalidation.entity## : ##ordervalidation.entity##
               ##IFordervalidation.name####lang.ordervalidation.name## : ##ordervalidation.name##
               ##ENDIFordervalidation.name##
               ##IFordervalidation.numorder####lang.ordervalidation.numorder## : ##ordervalidation.numorder##
               ##ENDIFordervalidation.numorder##
               ##IFordervalidation.orderdate####lang.ordervalidation.orderdate##  : ##ordervalidation.orderdate####ENDIFordervalidation.orderdate##
               ##IFordervalidation.state####lang.ordervalidation.state## : ##ordervalidation.state####ENDIFordervalidation.state##
               ##IFordervalidation.users####lang.ordervalidation.users## : ##ordervalidation.users####ENDIFordervalidation.users##

               ##IFordervalidation.comment####lang.ordervalidation.comment## : ##ordervalidation.comment####ENDIFordervalidation.comment##';
                $tmp['content_html'] = '&lt;p&gt;&lt;strong&gt;##lang.ordervalidation.url##&lt;/strong&gt; : ' . '&lt;a href=\\"##ordervalidation.url##\\"&gt;##ordervalidation.url##&lt;/a&gt;&lt;br /&gt;' . '&lt;br /&gt;&lt;strong&gt;##lang.ordervalidation.entity##&lt;/strong&gt; : ##ordervalidation.entity##&lt;br /&gt;' . ' ##IFordervalidation.name##&lt;strong&gt;##lang.ordervalidation.name##&lt;/strong&gt;' . ' : ##ordervalidation.name####ENDIFordervalidation.name##&lt;br /&gt;' . '##IFordervalidation.numorder##&lt;strong&gt;##lang.ordervalidation.numorder##&lt;/strong&gt;' . ' : ##ordervalidation.numorder####ENDIFordervalidation.numorder##&lt;br /&gt;##IFordervalidation.orderdate##&lt;strong&gt;##lang.ordervalidation.orderdate##&lt;/strong&gt;' . ' : ##ordervalidation.orderdate####ENDIFordervalidation.orderdate##&lt;br /&gt;' . '##IFordervalidation.state##&lt;strong&gt;##lang.ordervalidation.state##&lt;/strong&gt;' . ' : ##ordervalidation.state####ENDIFordervalidation.state##&lt;br /&gt;' . '##IFordervalidation.users##&lt;strong&gt;##lang.ordervalidation.users##&lt;/strong&gt;' . ' : ##ordervalidation.users####ENDIFordervalidation.users##&lt;br /&gt;&lt;br /&gt;' . '##IFordervalidation.comment##&lt;strong&gt;##lang.ordervalidation.comment##&lt;/strong&gt; : ##ordervalidation.comment####ENDIFordervalidation.comment##&lt;/p&gt;';
                $translation->add($tmp);
            }
            $notifs = array('New Order Validation' => 'ask', 'Confirm Order Validation' => 'validation', 'Cancel Order Validation' => 'undovalidation', 'Cancel Order' => 'cancel');
            $notification = new Notification();
            foreach ($notifs as $label => $name) {
                if (!countElementsInTable("glpi_notifications", "`itemtype`='PluginOrderOrder' AND `event`='{$name}'")) {
                    $tmp = array('name' => $label, 'entities_id' => 0, 'itemtype' => 'PluginOrderOrder', 'event' => $name, 'mode' => 'mail', 'comment' => '', 'is_recursive' => 1, 'is_active' => 1, 'date_mod' => $_SESSION['glpi_currenttime'], 'notificationtemplates_id' => $templates_id);
                    $notification->add($tmp);
                }
            }
        }
        $query_id = "SELECT `id`\n                       FROM `glpi_notificationtemplates`\n                       WHERE `itemtype`='PluginOrderOrder'\n                       AND `name` = 'Due date overtaken'";
        $result = $DB->query($query_id) or die($DB->error());
        if ($DB->numrows($result) > 0) {
            $templates_id = $DB->result($result, 0, 'id');
        } else {
            $tmp = array('name' => 'Due date overtaken', 'itemtype' => 'PluginOrderOrder', 'date_mod' => $_SESSION['glpi_currenttime'], 'comment' => '', 'css' => '');
            $templates_id = $template->add($tmp);
        }
        if ($templates_id) {
            $translation = new NotificationTemplateTranslation();
            if (!countElementsInTable($translation->getTable(), "`notificationtemplates_id`='{$templates_id}'")) {
                $tmp = array();
                $tmp['notificationtemplates_id'] = $templates_id;
                $tmp['language'] = '';
                $tmp['subject'] = '##order.action## ##order.entity##';
                $tmp['content_text'] = '##lang.order.entity## : ##order.entity##\\n' . ' \\n##FOREACHorders##\\n' . '##lang.order.item.name## : ##order.item.name##\\n ' . '##lang.order.item.numorder## : ##order.item.numorder##\\n ' . '##lang.order.item.orderdate## : ##order.item.orderdate##\\n ' . '##lang.order.item.duedate## : ##order.item.duedate##\\n ' . '##lang.order.item.deliverydate## : ##order.item.deliverydate##\\n ' . '##order.item.url## \\n ##ENDFOREACHorders##';
                $tmp['content_html'] = "##lang.order.entity## : ##order.entity##&lt;br /&gt; " . "&lt;br /&gt;##FOREACHorders##&lt;br /&gt;" . "##lang.order.item.name## : ##order.item.name##&lt;br /&gt; " . "##lang.order.item.numorder## : ##order.item.numorder##&lt;br /&gt; " . "##lang.order.item.orderdate## : ##order.item.orderdate##&lt;br /&gt; &lt;a&gt;" . "##lang.order.item.duedate## : ##order.item.duedate##&lt;br /&gt; &lt;/a&gt;&lt;a&gt;" . "##lang.order.item.deliverydate## : ##order.item.deliverydate##&lt;br /&gt; &lt;/a&gt;&lt;a&gt;" . "##order.item.url##&lt;/a&gt;&lt;br /&gt; ##ENDFOREACHorders##";
                $translation->add($tmp);
            }
            $notifs = array('Due date overtaken' => 'duedate');
            $notification = new Notification();
            foreach ($notifs as $label => $name) {
                if (!countElementsInTable("glpi_notifications", "`itemtype`='PluginOrderOrder' AND `event`='{$name}'")) {
                    $tmp = array('name' => $label, 'entities_id' => 0, 'itemtype' => 'PluginOrderOrder', 'event' => $name, 'mode' => 'mail', 'comment' => '', 'is_recursive' => 1, 'is_active' => 1, 'date_mod' => $_SESSION['glpi_currenttime'], 'notificationtemplates_id' => $templates_id);
                    $notification->add($tmp);
                }
            }
        }
        $template = new NotificationTemplate();
        $templates_id = false;
        $query_id = "SELECT `id`\n                       FROM `glpi_notificationtemplates`\n                       WHERE `itemtype`='PluginOrderOrder'\n                       AND `name` = 'Order Delivered'";
        $result = $DB->query($query_id) or die($DB->error());
        if ($DB->numrows($result) > 0) {
            $templates_id = $DB->result($result, 0, 'id');
        } else {
            $tmp = array('name' => 'Order Delivered', 'itemtype' => 'PluginOrderOrder', 'date_mod' => $_SESSION['glpi_currenttime'], 'comment' => '', 'css' => '');
            $templates_id = $template->add($tmp);
        }
        if ($templates_id) {
            $translation = new NotificationTemplateTranslation();
            if (!countElementsInTable($translation->getTable(), "`notificationtemplates_id`='{$templates_id}'")) {
                $tmp['notificationtemplates_id'] = $templates_id;
                $tmp['language'] = '';
                $tmp['subject'] = '##order.action## ##ordervalidation.name## ##ordervalidation.numorder##';
                $tmp['content_text'] = '##order.action##
##lang.ordervalidation.name## :
##ordervalidation.name##
##lang.ordervalidation.orderdate## :
##ordervalidation.orderdate##
##lang.ordervalidation.entity## :
##ordervalidation.entity##';
                $tmp['content_html'] = '&lt;p&gt;##order.action## &lt;br /&gt;&lt;br /&gt;&#160;
                ##lang.ordervalidation.name## : &lt;br /&gt;&#160;
                ##ordervalidation.name## &lt;br /&gt;&#160;
                ##lang.ordervalidation.orderdate## : &lt;br /&gt;&#160;
                ##ordervalidation.orderdate## &lt;br /&gt;&#160; &lt;br /&gt;&#160;
                ##lang.ordervalidation.entity## : &lt;br /&gt;&#160;##ordervalidation.entity##&lt;/p&gt;';
                $translation->add($tmp);
            }
        }
        $notifs = array('Order Delivered' => 'delivered');
        $notification = new Notification();
        foreach ($notifs as $label => $name) {
            if (!countElementsInTable("glpi_notifications", "`itemtype`='PluginOrderOrder' AND `event`='{$name}'")) {
                $tmp = array('name' => $label, 'entities_id' => 0, 'itemtype' => 'PluginOrderOrder', 'event' => $name, 'mode' => 'mail', 'comment' => '', 'is_recursive' => 1, 'is_active' => 1, 'date_mod' => $_SESSION['glpi_currenttime'], 'notificationtemplates_id' => $templates_id);
                $notification->add($tmp);
            }
        }
    }
 /**
  *	Используется для сохранения настроек.
  *
  *	@author Anthony Boutinov
  *	
  *	@param array $short_names			CM$DICTIONARY.SHORT_NAME массив
  *	@retval bool						Возвращает статус: успешно или нет
  */
 public function processPostRequestUpdateVars($short_names)
 {
     function processFileToSQL($key, &$sql)
     {
         $user_file_key = $key . '_file';
         $fileName = $_FILES[$user_file_key]['name'];
         $tmpName = $_FILES[$user_file_key]['tmp_name'];
         $fileSize = $_FILES[$user_file_key]['size'];
         $fileType = $_FILES[$user_file_key]['type'];
         $fp = fopen($tmpName, 'r');
         $content = fread($fp, filesize($tmpName));
         $content = addslashes($content);
         fclose($fp);
         if (!get_magic_quotes_gpc()) {
             $fileName = addslashes($fileName);
         }
         $sql = $sql . 'BLOB_VALUE="' . $content . '"';
     }
     $rows = $this->getDataTypesForParentByShortName($short_names);
     // sanitized inside
     $post_is_fine = true;
     foreach ($rows as $key => $value) {
         if ($value['DATA_TYPE'] == 'file' || $value['DATA_TYPE'] == 'text&file') {
             if ($_FILES[$key . '_file']['size'] == 0) {
                 $rows[$key]['field_doesnt_need_an_update'] = true;
             }
         } else {
             if ($value['DATA_TYPE'] == 'checkbox') {
                 if (isset($_POST[$key])) {
                     $_POST[$key] = "T";
                 } else {
                     $_POST[$key] = "F";
                 }
             } else {
                 if (!isset($_POST[$key])) {
                     Notification::add("POST value for '{$key}' is not set.", 'danger');
                     $post_is_fine = false;
                 }
             }
         }
     }
     if (!$post_is_fine) {
         return false;
     }
     foreach ($rows as $key => $value) {
         if (isset($value['field_doesnt_need_an_update']) && $value['field_doesnt_need_an_update']) {
             continue;
         }
         $sql = 'update SP$VAR set ';
         if ($value['DATA_TYPE'] == 'file') {
             processFileToSQL($key, $sql);
         } else {
             if ($value['DATA_TYPE'] == 'text&file') {
                 processFileToSQL($key, $sql);
                 $sql = $sql . ', ';
             }
             $sql = $sql . 'VALUE="' . htmlspecialchars($_POST[$key]) . '"';
         }
         $sql = $sql . ' WHERE ID_DB_USER='******' AND ID_DICTIONARY=' . $value['ID_DICTIONARY'];
         $this->getQueryResultWithErrorNoticing($sql);
     }
     Notification::add("Изменения сохранены!", 'success');
     return true;
 }
示例#14
0
/**
 * @param $text string
 * @param $type string Notification type
 * @param $list_id integer|null
 * @param $task_id integer|null
 */
function addNotification($text, $type, $list_id = null, $task_id = null)
{
    // only add Notifications if we are on multi user mode
    if (Config::get('multiuser') == 1) {
        try {
            Notification::add($text, $type, $list_id, $task_id);
        } catch (Exception $e) {
            var_dump($e->getMessage());
        }
    }
}
示例#15
0
    $content_comment = $_POST['my_comment'];
    $id_article = $_POST['id_article'];
    $author = $_SESSION['login'];
    $new_comment = new Comment($id_article, $author, $content_comment);
    $new_comment->add();
    $bdd = new PDO('mysql:host=localhost;dbname=bavn', 'root', '');
    $auteur_article = $bdd->query('SELECT id FROM members  WHERE id IN(SELECT id_author FROM articles WHERE id="' . $id_article . '")');
    $auteur_article = $auteur_article->fetch()[0];
    $commentateurs_article = $bdd->query('SELECT id, pseudo FROM members  WHERE pseudo IN(SELECT pseudo FROM comments WHERE id_article="' . $id_article . '")');
    $commentateurs_article = $commentateurs_article->fetchAll();
    $nombre_commentateurs = count($commentateurs_article);
    for ($i = 0; $i < $nombre_commentateurs + 1; $i++) {
        if ($i < $nombre_commentateurs) {
            $cur_id = $commentateurs_article[$i]['id'];
            $cur_pseudo = $commentateurs_article[$i]['pseudo'];
            if ($cur_pseudo != $author) {
                $new_not = new Notification($cur_id, $id_article, "Un nouveau commentaire sur une publication que vous suivez est apparu", '', 0);
            } else {
                $auteur_article = -1;
            }
        } else {
            if ($auteur_article != -1) {
                $new_not = new Notification($auteur_article, $id_article, "Un nouveau commentaire sur votre publication est apparu", '', 0);
            }
        }
        if (isset($new_not)) {
            $new_not->add();
        }
    }
    unset($new_comment);
}
示例#16
0
 /**
  * Function checks whether or not a user has the requested permission.
  *
  * @param string $perm_code	Permission code
  * @param int $gid			Group id if applicable
  * @param bool $redir		Whether or not to redirect on a failed permission
  * @return bool				Whether or not the user has the required permission
  */
 public function requirePermission($perm_code = "PV__300", $gid = null, $redir = false)
 {
     if (!isset($perm_code)) {
         $allow = false;
     } else {
         $code = explode("__", $perm_code);
         $group = isset($gid) ? $gid : "site";
         if (isset(User::$current_user->permissions[$group][$code[0]])) {
             $allow = User::$current_user->permissions[$group][$code[0]] <= $code[1];
         } else {
             $allow = false;
         }
     }
     if (!$allow && $redir) {
         $_SESSION["login_redirect"] = $this->_request_path;
         Notification::add("You do not have the authentication level to view that page.");
         Notification::add("Once you login, you will be returned to:" . $this->_request_path);
         Page::redirect("/home/login");
     }
     return $allow;
 }
示例#17
0
 public function actionAddComment()
 {
     $keyid = zmf::val('k', 2);
     $to = zmf::val('to', 2);
     $type = zmf::val('t', 1);
     $content = zmf::val('c', 1);
     $email = zmf::val('email', 1);
     $username = zmf::val('username', 1);
     if (!isset($type) or !in_array($type, array('posts'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     if ($this->uid) {
         $status = Posts::STATUS_PASSED;
         $uid = $this->uid;
     } else {
         if (!$username) {
             $this->jsonOutPut(0, '请填写称呼');
         }
         zmf::setCookie('noLoginUsername', $username, 2592000);
         if ($email != '') {
             $validator = new CEmailValidator();
             if (!$validator->validateValue($email)) {
                 $this->jsonOutPut(0, '请填写正确的邮箱地址');
             }
             zmf::setCookie('noLoginEmail', $email, 2592000);
         }
         $status = Posts::STATUS_STAYCHECK;
         $uid = 0;
         if (zmf::actionLimit($type, $keyid, 5, 86400, true)) {
             $this->jsonOutPut(0, '操作太频繁,请稍后再试');
         }
     }
     $postInfo = Posts::model()->findByPk($keyid);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您所评论的内容不存在');
     }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     $model = new Comments();
     $toNotice = true;
     $touid = $postInfo['uid'];
     if ($to) {
         $comInfo = Comments::model()->findByPk($to);
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'] > 0 ? $comInfo['uid'] : '';
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => '', 'tocommentid' => $to, 'status' => $status, 'username' => $username, 'email' => $email);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 if ($status == Posts::STATUS_PASSED) {
                     Posts::updateCommentsNum($keyid);
                 }
                 $_content = '您的文章有了新的评论,' . $_url;
             }
             if ($to && $_url) {
                 $_content = '您的评论有了新的回复,' . $_url;
             }
             if ($toNotice) {
                 $_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
                 Notification::add($_noticedata);
             }
             if ($uid) {
                 $intoData['loginUsername'] = $this->userInfo['truename'];
             }
             $html = $this->renderPartial('/posts/_comment', array('data' => $intoData, 'postInfo' => $postInfo), true);
             $this->jsonOutPut(1, $html);
         } else {
             $this->jsonOutPut(0, '新增评论失败');
         }
     } else {
         $this->jsonOutPut(0, '新增评论失败');
     }
 }
示例#18
0
文件: user.php 项目: anqh/anqh
 /**
  * Added as a friends.
  *
  * @static
  * @param  Model_User  $user
  * @param  Model_User  $friend
  */
 public static function friend(Model_User $user = null, Model_User $friend = null)
 {
     if ($user && $friend) {
         parent::add($user, $friend, self::CLASS_USER, self::TYPE_FRIEND);
     }
 }
示例#19
0
 private function add($type = '')
 {
     $uid = zmf::filterInput(Yii::app()->request->getParam('uid'), 't', 1);
     if (!$uid) {
         $uid = zmf::uid();
     }
     if (zmf::config('fbLoginOnly')) {
         if (!$uid) {
             $this->jsonOutPut(0, Yii::t('default', 'fbLoginOnly'));
         }
     }
     $url = zmf::filterInput(Yii::app()->request->getParam('url'), 't', 1);
     $email = zmf::filterInput(Yii::app()->request->getParam('email'), 't', 1);
     $content = zmf::filterInput(Yii::app()->request->getParam('content'), 't', 1);
     $ip = zmf::filterInput(Yii::app()->request->getParam('ip'), 't', 1);
     $appversion = zmf::filterInput(Yii::app()->request->getParam('appversion'), 't', 1);
     $os = zmf::filterInput(Yii::app()->request->getParam('os'), 't', 1);
     $platform = zmf::filterInput(Yii::app()->request->getParam('platform'), 't', 1);
     $time = zmf::filterInput(Yii::app()->request->getParam('time'), 't', 1);
     if (!$ip) {
         $ip = ip2long(Yii::app()->request->userHostAddress);
     }
     if (!$platform) {
         $platform = Yii::app()->request->getUserAgent();
     }
     if ($type == '' || !in_array($type, array('pc', 'mobile', 'ios', 'android'))) {
         $type = 'pc';
     }
     if (!$time) {
         $time = zmf::now();
     }
     $cacheKey = 'feedback_' . $ip;
     if ($content == '') {
         $this->jsonOutPut(0, Yii::t('default', 'fbNoEmpty'));
     }
     if (zmf::config('fbTimesLimit')) {
         $times = intval(zmf::getFCache($cacheKey));
         $_time = $times + 1;
         //fbLimitTimes
         zmf::setFCache($cacheKey, $_time, 60);
         if ($_time >= zmf::config('fbLimitTimes')) {
             $this->jsonOutPut(0, Yii::t('default', 'fbTimesLimit'));
         }
     }
     $data = array('uid' => $uid, 'url' => $url, 'email' => $email, 'content' => $content, 'ip' => $ip, 'cTime' => $time, 'status' => Posts::STATUS_STAYCHECK, 'classify' => $type, 'appversion' => $appversion, 'os' => $os, 'platform' => $platform);
     $model = new Feedback();
     $model->attributes = $data;
     if ($model->validate()) {
         if ($model->save()) {
             if (zmf::config("defaultNoticeUid")) {
                 $_data = array('uid' => zmf::config("defaultNoticeUid"), 'content' => ($email != '' ? $email . '反馈:' : '新反馈:') . $content, 'type' => 'feedback', 'from_id' => rand(1, 100000), 'from_idtype' => 'feedback');
                 Notification::add($_data);
             }
             $this->jsonOutPut(1, Yii::t('default', 'fbThanking'));
         } else {
             $this->jsonOutPut(0, Yii::t('default', 'fbThanking'));
         }
     } else {
         $this->jsonOutPut(0, Yii::t('default', 'notvalidate'));
     }
 }
示例#20
0
 public function settingsPost()
 {
     $notification = new Notification();
     $resp = $this->api->invoke('/manage/settings.json', EpiRoute::httpPost);
     if ($resp['code'] === 200) {
         $notification->add('Your settings were successfully saved.', Notification::typeFlash, Notification::modeConfirm);
     } else {
         $notification->add('There was a problem updating your settings.', Notification::typeFlash, Notification::modeError);
     }
     $this->route->redirect('/manage/settings');
 }
示例#21
0
        } else {
            if ($_POST['form-name'] == 'password-reset-set-new') {
                if (isset($_POST['LOGIN']) && isset($_POST['PASSWORD_RESET_TOKEN'])) {
                    if ($_POST['password'] != $_POST['repeat-password']) {
                        Notification::add("Ошибка: Пароли не совпадают!", 'danger');
                    }
                    $responce = $database->setNewPasswordUsingResetPasswordToken($_POST['LOGIN'], $_POST['PASSWORD_RESET_TOKEN'], $_POST['password']);
                    if ($responce) {
                        Notification::add('Пароль успешно изменен! Теперь вы можете войти в Личный кабинет.', 'success');
                    } else {
                        Notification::add('Ошибка: Переданы недействительные данные.', 'danger');
                    }
                } else {
                    Notification::add('Ошибка: Переданы недействительные данные.', 'danger');
                }
            }
        }
    }
} else {
    if (isset($_GET['l']) && isset($_GET['t'])) {
        $responce = $database->checkPasswordResetToken($_GET['l'], $_GET['t']);
        if ($responce) {
            include 'includes/modules/admin-login-resetPassword.php';
            exit;
        } else {
            Notification::add('Ошибка: Переданы недействительные данные.', 'danger');
        }
    }
}
// Страница по умолчанию
include 'includes/modules/admin-login-default.php';
示例#22
0
 /**
  * Attempts to remove a user from an event.
  *
  * @param int $eid	Event id of the applicable event
  * @return bool		Whether or not rows were affected
  */
 static function removeAttendeeFromEvent($eid)
 {
     if (!isset($eid)) {
         Notification::add("Event ID must be set to remove attendee");
         return false;
     }
     $stmt = Database::getDB()->prepare("\r\n\t\t\tDELETE FROM users_events\r\n\t\t\tWHERE\r\n\t\t\t\te_eid = ? AND\r\n\t\t\t\tu_uid = ?\r\n\t\t");
     $stmt->bind_param("ii", $eid, User::$current_user->uid);
     $stmt->execute() or die($stmt->error);
     $stmt->store_result();
     $rows = $stmt->affected_rows;
     $stmt->close();
     return $rows > 0;
 }
示例#23
0
 public function afterCreate($product)
 {
     Notification::add($product->id, 'Product');
 }
示例#24
0
 function edit()
 {
     RoutingEngine::setPage("runnDAILY Edit Training Entry", "PV__300");
     if (!isset($_GET["tid"])) {
         Notification::add("That training entry does not exist.");
         Page::redirect("/training");
     }
     $tid = $_GET["tid"];
     $training = TrainingLog::getItem($tid);
     if ($training->uid != User::$current_user->uid) {
         Notification::add("You are not allowed to edit that entry");
         Page::redirect("/training");
     }
     $stmt = Database::getDB()->prepare("\r\n\t\t\tSELECT t_type_id, t_type_name\r\n\t\t\tFROM training_types\r\n\t\t");
     $stmt->execute();
     $stmt->store_result();
     $types = array();
     while ($row = $stmt->fetch_assoc()) {
         $types[$row["t_type_id"]] = $row["t_type_name"];
     }
     $stmt->close();
     RoutingEngine::getSmarty()->assign("t_types", $types);
     RoutingEngine::getSmarty()->assign("t_item", $training);
     RoutingEngine::getSmarty()->display("training/edit.tpl");
     exit;
 }
示例#25
0
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("notification", 'r');
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
$notification = new Notification();
if (isset($_POST["add"])) {
    $notification->check(-1, 'w', $_POST);
    $newID = $notification->add($_POST);
    Event::log($newID, "notifications", 4, "notification", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
    Html::redirect($_SERVER['PHP_SELF'] . "?id={$newID}");
} else {
    if (isset($_POST["delete"])) {
        $notification->check($_POST["id"], 'd');
        $notification->delete($_POST);
        Event::log($_POST["id"], "notifications", 4, "notification", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
        $notification->redirectToList();
    } else {
        if (isset($_POST["update"])) {
            $notification->check($_POST["id"], 'w');
            $notification->update($_POST);
            Event::log($_POST["id"], "notifications", 4, "notification", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
            Html::back();
        } else {
示例#26
0
 public function afterCreate($user)
 {
     Notification::add($user->id, 'User');
 }
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
            Notification::add($notification_user->getID(), $proxy_id, $evaluation_id, isset($pending_evaluation["event_id"]) && $pending_evaluation["event_id"] ? $pending_evaluation["event_id"] : $pending_evaluation["event_id"]);
        }
    }
}
//queue notifications for each user with the evaluations which have closed for them in the last 24 hours.
$query = "SELECT *, '0' AS `event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND a.`evaluation_finish` >= " . $db->qstr(strtotime("-10 weeks")) . "\n\t\t\tAND a.`evaluation_finish` <= " . $db->qstr(time()) . "\n\t\t\tAND c.`target_shortname` NOT IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cohort'\n\t\t\tJOIN `group_members` AS h\n\t\t\tON g.`evaluator_value` = h.`group_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`member_active`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'cgroup_id'\n\t\t\tJOIN `course_group_audience` AS h\n\t\t\tON g.`evaluator_value` = h.`cgroup_id`\n\t\t\tAND h.`proxy_id` = f.`etype_id`\n\t\t\tAND h.`active` = 1\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT) . "\n\t\t\t\n\t\t\tUNION\n\t\t\t\n\t\t\tSELECT a.*, b.*, c.*, e.`event_id` FROM `evaluations` AS a\n\t\t\tJOIN `evaluation_forms` AS b\n\t\t\tON a.`eform_id` = b.`eform_id`\n\t\t\tJOIN `evaluations_lu_targets` AS c\n\t\t\tON b.`target_id` = c.`target_id`\n\t\t\tAND c.`target_shortname` IN ('preceptor', 'rotation_core', 'rotation_elective')\n\t\t\tJOIN `evaluation_targets` AS d\n\t\t\tON a.`evaluation_id` = d.`evaluation_id`\n\t\t\tAND d.`target_type` = 'rotation_id'\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`events` AS e\n\t\t\tON d.`target_value` = e.`rotation_id`\n\t\t\tAND a.`evaluation_start` <= e.`event_finish`\n\t\t\tAND a.`evaluation_finish` >= e.`event_finish`\n\t\t\tJOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS f\n\t\t\tON e.`event_id` = f.`event_id`\n\t\t\tJOIN `evaluation_evaluators` AS g\n\t\t\tON a.`evaluation_id` = g.`evaluation_id`\n\t\t\tAND g.`evaluator_type` = 'proxy_id'\n\t\t\tAND g.`evaluator_value` = f.`etype_id`\n\t\t\tWHERE a.`evaluation_start` <= " . $db->qstr(strtotime("-1 day")) . "\n\t\t\tAND e.`event_finish` >= " . $db->qstr(time() - CLERKSHIP_EVALUATION_LOCKOUT) . "\n\t\t\tAND e.`event_finish` <= " . $db->qstr(time() - CLERKSHIP_EVALUATION_TIMEOUT);
$ended_evaluations = $db->GetAll($query);
if ($ended_evaluations) {
    foreach ($ended_evaluations as $evaluation) {
        $overdue_evaluations[$evaluation["evaluation_id"] . (isset($evaluation["event_id"]) && $evaluation["event_id"] ? "-" . $evaluation["event_id"] : "")] = Models_Evaluation::getOverdueEvaluations($evaluation);
    }
}
foreach ($overdue_evaluations as $overdue_evaluation_users) {
    foreach ($overdue_evaluation_users as $overdue_evaluation) {
        $evaluation_id = $overdue_evaluation["evaluation_id"];
        require_once "Models/notifications/NotificationUser.class.php";
        require_once "Models/notifications/Notification.class.php";
        $proxy_id = $overdue_evaluation["user"]["id"];
        $notification_user = NotificationUser::get($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        if (!$notification_user) {
            $notification_user = NotificationUser::add($proxy_id, "evaluation_overdue", $evaluation_id, $proxy_id);
        }
        $query = "SELECT * FROM `notifications` \n                    WHERE `nuser_id` = " . $db->qstr($notification_user->getID()) . " \n                    AND `proxy_id` = " . $db->qstr($proxy_id) . "\n                    AND (`sent_date` = 0 OR `sent_date` >= " . $db->qstr(strtotime("-7 days")) . ")";
        $recent_notifications = $db->GetAll($query);
        if (!isset($recent_notifications) || !$recent_notifications) {
            Notification::add($notification_user->getID(), $proxy_id, $evaluation_id, isset($overdue_evaluation["event_id"]) && $overdue_evaluation["event_id"] ? $overdue_evaluation["event_id"] : $overdue_evaluation["event_id"]);
        }
    }
}
示例#28
0
 /**
  * 问题的赞成反对及其他点赞
  */
 public function actionFavor()
 {
     //        Users::checkPower('favor');
     $type = zmf::filterInput($_POST['type'], 't', 1);
     $keyid = zmf::filterInput($_POST['keyid']);
     if (!$keyid) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!isset($type) or empty($type) or !in_array($type, array('naodong'))) {
         //Forbidden::updateTimes();
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (zmf::actionLimit('favor-' . $type, $keyid)) {
         $this->jsonOutPut(0, '操作太频繁,请稍后再试');
     }
     if ($type == 'naodong') {
         $classify = 'favorNaodong';
         $model = new Naodong();
         $field = 'favors';
     }
     if (!$model) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     $info = $model->findByPk($keyid);
     if (!$info) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     } elseif ($info['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您操作的内容正在审核或已删除');
     }
     //        elseif ($info['uid'] == zmf::uid()) {
     //            $this->jsonOutPut(0, '不能操作自己的哦~');
     //        }
     if (UserAction::checkAction($keyid, $classify)) {
         if (UserAction::delAction($keyid, $classify)) {
             if ($field) {
                 $model->updateCounters(array($field => -1), 'id=:id', array(':id' => $keyid));
             }
             $this->jsonOutPut(3, '取消赞成功');
         } else {
             $this->jsonOutPut(0, '取消赞失败');
         }
     } else {
         if (UserAction::recordAction($keyid, $classify, $info['uid'])) {
             if ($field) {
                 if ($model->updateCounters(array($field => 1), 'id=:id', array(':id' => $keyid))) {
                     if ($type == 'naodong') {
                         $_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid));
                         $_content = '您的作品有了新的赞,' . $_url;
                         $toNotice = true;
                     }
                     if ($toNotice) {
                         $_noticedata = array('uid' => $info['uid'], 'authorid' => $this->uid, 'content' => $_content, 'new' => 1, 'type' => 'favor', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
                         Notification::add($_noticedata);
                     }
                 }
             }
             $this->jsonOutPut(1, '添加赞成功');
         } else {
             $this->jsonOutPut(0, '添加赞失败');
         }
     }
 }
示例#29
0
         } else {
             $PROCESSED_REQUEST["request_expires"] = 0;
         }
         $PROCESSED_REQUEST["evaluation_id"] = $RECORD_ID;
         $PROCESSED_REQUEST["proxy_id"] = $ENTRADA_USER->getId();
         $PROCESSED_REQUEST["target_proxy_id"] = $associated_evaluator;
         $PROCESSED_REQUEST["request_created"] = time();
         $PROCESSED_REQUEST["request_fulfilled"] = 0;
         if ($db->AutoExecute("evaluation_requests", $PROCESSED_REQUEST, "INSERT") && ($request_id = $db->Insert_Id())) {
             require_once "Models/notifications/Notification.class.php";
             require_once "Models/notifications/NotificationUser.class.php";
             $notification_user = NotificationUser::get($associated_evaluator, "evaluation_request", $RECORD_ID, $ENTRADA_USER->getId());
             if (!$notification_user) {
                 $notification_user = NotificationUser::add($associated_evaluator, "evaluation_request", $RECORD_ID, $ENTRADA_USER->getId());
             }
             if (Notification::add($notification_user->getID(), $ENTRADA_USER->getId(), $RECORD_ID)) {
                 $notifications_sent++;
             } else {
                 add_error("An issue was encountered while attempting to send a notification to a user [" . get_account_data("wholename", $associated_evaluator) . "] requesting that they complete an evaluation [" . $evaluation_title . "] for you. The system administrator has been notified of this error, please try again later.");
                 application_log("Unable to send notification requesting an evaluation be completed to evaluator [" . $associated_evaluator . "] for evaluation_id [" . $RECORD_ID . "].");
             }
         } else {
             add_error("Unable to create a request entry for this evaluation. The system administrator was notified of this error; please try again later.");
             application_log("Unable to create a request entry for this evaluator [" . $associated_evaluator . "] for evaluation_id [" . $RECORD_ID . "]. Database said: " . $db->ErrorMsg());
         }
     } else {
         add_error("The selected evaluator [" . get_account_data("wholename", $associated_evaluator) . "] has already completed this evaluation [" . $evaluation_title . "] for you, and is unable to attempt it again.");
     }
 } else {
     add_error("The selected evaluator [" . get_account_data("wholename", $associated_evaluator) . "] has already completed this evaluation [" . $evaluation_title . "] the maximum number of times, and is therefore unable to attempt it again.");
 }
示例#30
0
 public function afterCreate($order)
 {
     Notification::add($order->id, 'Order');
 }