function create($info, $data) { $notifications = new Notifications(); $notifications->info = $info; $notifications->data = $data; return $notifications->Create(); }
public static function note($msg, $opt = array(0, 0, 0), $is_assign = 1) { list($creator, $destination, $shared_id) = $opt; $note = new Notifications(); $note->msg = $msg; $note->time = time(); $note->creator_id = $creator; $note->dest_id = $destination; $note->shared_id = $shared_id; $note->status = $is_assign == 2 ? 2 : 1; return $note->validate() && $note->save(); }
public function g() { session_start(); $data = array(); $loginClass = new Login(); $id = $loginClass->isLogged(); if ($id) { $notif = new Notifications(); $notif->newNotification(2, 0); } else { $this->redirect(''); } }
public static function update() { $post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page')); $errors = array(); if (empty($post['sitename'])) { $errors[] = 'You need a site sitename'; } if (empty($post['description'])) { $errors[] = 'You need a site description'; } if (empty($post['theme'])) { $errors[] = 'You need a theme'; } if (count($errors)) { Notifications::set('error', $errors); return false; } $post['sitename'] = htmlentities($post['sitename']); $post['description'] = htmlentities($post['description']); foreach ($post as $key => $value) { Db::update('meta', array('value' => $value), array('key' => $key)); } Notifications::set('success', 'Your metadata has been updated'); return true; }
public function add($user_follow, $user_followed, $type) { $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed)); $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed)); $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed)); if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) { return FALSE; } $model = new Follow(); $model->user_follow = $user_follow; $model->user_followed = $user_followed; $model->created_at = time(); $model->update_at = time(); $model->type = $type; $user_follow_data = User::model()->findByPk($user_follow); $user_followed_data = User::model()->findByPk($user_followed); if ($user_follow != Yii::app()->session['user_id']) { $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti'))); Notifications::model()->add($arr_noti); } if ($model->save(FALSE)) { return TRUE; } return FALSE; }
public static function update() { $post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page', 'auto_published_comments', 'posts_per_page')); $errors = array(); if (empty($post['sitename'])) { $errors[] = 'You need a site sitename'; } if (empty($post['description'])) { $errors[] = 'You need a site description'; } if (empty($post['theme'])) { $errors[] = 'You need a theme'; } // auto publish comments $post['auto_published_comments'] = $post['auto_published_comments'] ? 1 : 0; // format posts per page, must be a whole number above 1 defaults to 10 if a invalid number is entered $post['posts_per_page'] = ($posts_per_page = intval($post['posts_per_page'])) > 0 ? $posts_per_page : 10; if (count($errors)) { Notifications::set('error', $errors); return false; } foreach ($post as $key => $value) { Db::update('meta', array('value' => $value), array('key' => $key)); } Notifications::set('success', 'Your metadata has been updated'); return true; }
/** * @url POST import */ public function post() { try { $session = Session::singleton(); $allowedRoles = (array) Config::get('allowedRolesForExcelImport', 'excelImport'); if (Config::get('loginEnabled') && !is_null($allowedRoles)) { $ok = false; $sessionRoles = Role::getAllSessionRoles(); foreach ($sessionRoles as $role) { if (in_array($role->label, $allowedRoles)) { $ok = true; } } if (!$ok) { throw new Exception("You do not have access to import excel files", 401); } } if (is_uploaded_file($_FILES['file']['tmp_name'])) { // Parse: $parser = new ImportExcel($_FILES['file']['tmp_name']); $result = $parser->ParseFile(); unlink($_FILES['file']['tmp_name']); } else { Notifications::addError('No file uploaded'); } $result = array('notifications' => $result, 'files' => $_FILES); return $result; } catch (Exception $e) { throw new RestException($e->getCode(), $e->getMessage()); } }
function SendSMS($phonenumber, $message) { $config = Config::get('sendSMSConfig', 'execEngine'); $username = $config['username']; $password = $config['password']; $sender = $config['sender']; Notifications::addLog('Username = '******'ExecEngine'); // Set the Messabeird username and password, and create an instance of the MessageBird class $sms = new MessageBird($username, $password); // Set the sender, could be a number (16 numbers) or letters (11 characters) $sms->setSender($sender); // Add the destination mobile number. // This method can be called several times to add have more then one recipient for the same message $sms->addDestination($phonenumber); //e.g. $sms->addDestination('31600000000'); // Set an reference, optional // $sms->setReference('123456789'); // Set a schedule date-time, optional // $sms->setTimestamp('2014-01-01 10:02'); // Replace non GSM-7 characters by appropriate valid GSM-7 characters // $sms->setReplacechars(false); // If you want a dlr notification of the message send to another url then that you have set on the web site, you can use this parameter. Don't forget to set a reference! // $sms->setDlrUrl('http://www.example.com/dlr_url.php'); // If $test is TRUE, then the message is not actually sent or scheduled, and there will be no credits deducted. // $sms->setTest(true); // Send the message to the destination(s) $sms->sendSms($message); Notifications::addLog("ResponseCode: " . $sms->getResponseCode(), 'ExecEngine'); Notifications::addLog("ResponseMessage: " . $sms->getResponseMessage(), 'ExecEngine'); Notifications::addLog("Balance: " . $sms->getCreditBalance(), 'ExecEngine'); }
private static function pushNotification($userKey, $message, $title = null, $url = null, $urltitle = null) { Notifications::addLog('Pushover[pushNotification' . ']; $userKey=[' . $userKey . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING'); $notification = new Pushover(); $token = Config::get('applicationToken', 'msg_pushover'); if (is_null($token)) { throw new Exception("Pushover - Application token not specified", 500); } if (is_null($userKey)) { throw new Exception("Pushover - User key not specified", 500); } $notification->setToken($token); $notification->setUser($userKey); $notification->setMessage($message); if (!is_null($title)) { $notification->setTitle($title); } $notification->setHtml(1); $notification->setUrl($url); $notification->setUrlTitle($urltitle); if (!$notification->send()) { Notifications::addError("Pushover - Error in sending a notification to '{$userKey}'"); } else { Notifications::addSuccess('Pushover message sent.'); } }
public static function add($post_id) { $post = Input::post(array('name', 'email', 'text')); $errors = array(); if (empty($post['name'])) { $errors[] = 'Please enter your name'; } if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'Please enter a valid email address'; } if (empty($post['text'])) { $errors[] = 'Please enter your comments'; } if (count($errors)) { Notifications::set('error', $errors); return false; } $post['date'] = time(); $post['status'] = Config::get('metadata.auto_published_comments', 0) ? 'published' : 'pending'; $post['post'] = $post_id; // encode any html $post['text'] = Html::encode($post['text']); Db::insert('comments', $post); Notifications::set('success', 'Your comment has been sent'); return true; }
public static function add($post_id) { $post = Input::post(array('name', 'email', 'text')); $errors = array(); if (empty($post['name'])) { $errors[] = 'Please enter ayour name'; } if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'Please enter a valid email address'; } if (empty($post['text'])) { $errors[] = 'Please enter your comments'; } if (count($errors)) { Notifications::set('error', $errors); return false; } $post['date'] = time(); $post['status'] = 'pending'; $post['post'] = $post_id; $keys = array(); $values = array(); $args = array(); foreach ($post as $key => $value) { $keys[] = '`' . $key . '`'; $values[] = '?'; $args[] = $value; } $sql = "insert into comments (" . implode(', ', $keys) . ") values (" . implode(', ', $values) . ")"; Db::query($sql, $args); Notifications::set('success', 'Your comment has been sent'); return true; }
public function action_add() { $post = $this->request->post(); if ($post) { $this->template->data["post"] = $post; if ($post['role'] == "") { array_push($this->template->data["errors"], array("Role" => __("User role must be set."))); } else { /* automatically obtain password if user set none */ if (empty($post['password'])) { $post['password'] = Auth::randomPassword(); $post['password_confirm'] = $post['password']; } try { $user = ORM::factory('User')->create_user($post, array('email', 'password')); $user->add('roles', ORM::factory('Role', array('name' => $post['role']))); $this->template->data["post"] = NULL; } catch (ORM_Validation_Exception $e) { $this->template->data["errors"] = $e->errors('models'); } if (empty($this->template->data["errors"])) { Notifications::factory()->new_user_account($post['email'], $post); $this->redirect('/admin/user/all'); } } } $this->template->data["roles"] = ORM::factory("Role")->get_roles(); }
private static function saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source) { if (array_key_exists($fullRelationSignature, Config::get('mutationConcepts', 'MutationExtension'))) { Notifications::addLog("Save mutation on '{$fullRelationSignature}' (editUpdate)", 'Mutation'); $mutConcept = Config::get('mutationConcepts', 'MutationExtension')[$fullRelationSignature]; $database = Database::singleton(); $database->setTrackAffectedConjuncts(false); // Don't track affected conjuncts for Mutation concept and relations; // New Mutation $mut = $database->addAtomToConcept(Concept::createNewAtom($mutConcept), $mutConcept); // Add mut info $database->editUpdate('mutRelation', false, $mut, 'Mutation', $fullRelationSignature, 'Relation'); $database->editUpdate('mutDateTime', false, $mut, 'Mutation', date(DATE_ISO8601), 'DateTime'); if ($source == 'User') { $user = Session::getSessionUserId(); } else { $user = $source; } $database->editUpdate('mutBy', false, $mut, 'Mutation', $user, 'User'); $database->editUpdate('mutOp', false, $mut, 'Mutation', $operation, 'Operation'); // $database->editUpdate('mutReason', false, $mut, 'Mutation', 'zomaar', 'MutationReason'); // TODO: get reason from somewhere $database->editUpdate('mutValue', false, $mut, 'Mutation', $modifiedAtom, 'MutationValue'); $database->editUpdate('mutStable', false, $mut, $mutConcept, $stableAtom, $stableConcept); $database->editUpdate('mutPublish', false, $mut, 'Mutation', $mut, 'Mutation'); $database->setTrackAffectedConjuncts(true); // Enable tracking of affected conjuncts again!! } }
public function create_new($post, $discussion_id, $reply_comment_id = NULL) { $comment = NULL; if (isset($post['text']) && isset($discussion_id)) { $user = Auth::instance()->get_user(); $comment = Model::factory('Comment'); $values = array(); $values["text"] = $post['text']; $values["discussion_id"] = $discussion_id; if ($user) { $values["user_id"] = $user->id; } else { if ($post['author_visitor'] != "") { $values["author_visitor"] = $post['author_visitor']; } } $values["reply_comment_id"] = $reply_comment_id; $comment->values($values, array_keys($values)); try { $comment->save(); Notifications::factory()->new_comment($comment->reload()); } catch (ORM_Validation_Exception $e) { $errors = $e->errors('models'); } } return $comment; }
/** * @url GET run * @param array $roleIds */ public function run($roleIds = null) { try { $session = Session::singleton(); $session->activateRoles($roleIds); // Check sessionRoles if allowedRolesForRunFunction is specified $allowedRoles = Config::get('allowedRolesForRunFunction', 'execEngine'); if (!is_null($allowedRoles)) { $ok = false; foreach ($session->getSessionRoles() as $role) { if (in_array($role->label, $allowedRoles)) { $ok = true; } } if (!$ok) { throw new Exception("You do not have access to run the exec engine", 401); } } ExecEngine::run(true); $db = Database::singleton(); $db->closeTransaction('Run completed', false, true, false); $result = array('notifications' => Notifications::getAll()); return $result; } catch (Exception $e) { throw new RestException($e->getCode(), $e->getMessage()); } }
/** * @url GET run */ public function run() { try { $session = Session::singleton(); $db = Database::singleton(); $allowedRoles = (array) Config::get('allowedRolesForRunFunction', 'execEngine'); if (Config::get('loginEnabled') && !is_null($allowedRoles)) { $ok = false; $sessionRoles = Role::getAllSessionRoles(); foreach ($sessionRoles as $role) { if (in_array($role->label, $allowedRoles)) { $ok = true; } } if (!$ok) { throw new Exception("You do not have access to run the exec engine", 401); } } $session->setRole(); ExecEngine::runAllRules(); $db->closeTransaction('Run completed', false, true, false); $result = array('notifications' => Notifications::getAll()); return $result; } catch (Exception $e) { throw new RestException($e->getCode(), $e->getMessage()); } }
public function mark_as_read($id) { $notification = Notifications::find($id); $notification->read = true; $notification->save(); return $notification; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Notifications::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, Yii::t('site', '404_Error')); } return $model; }
public function getNotification($user_id, $limit, $offset) { $criteria = new CDbCriteria(); $criteria->limit = $limit; $criteria->offset = $offset; $criteria->condition = "user_id = {$user_id}"; return $data = Notifications::model()->findAll($criteria); }
public function userMenus() { $helper = Notifications::getInstance(); $ret['name'] = $helper->getModule()->getVar('name'); $ret['link'] = 'index.php'; $ret['image'] = $helper->url('icons/logo_small.png'); return $ret; }
function CreateCvrMsgTitle($nonce) { if (!$nonce) { throw new Exception("CreateCvrMsgTitle - cannot make TITLE as no nonce is provided", 500); } Notifications::addLog('Created a challenge message for CEPValidation using [' . $nonce, 'MESSAGING'); return 'Validation code: ' . $nonce; }
public function ParseFile() { Notifications::addLog('------------------------- EXCEL IMPORT STARTED -------------------------', 'ExcelImport'); $this->ProcessFileContent(); Notifications::addLog('------------------------- END OF EXCEL IMPORT -------------------------', 'ExcelImport'); // Close transaction => ROLLBACK or COMMIT. $this->db->closeTransaction('File uploaded', false, true, false); return Notifications::getAll(); }
public function getRead($id) { $data = Notifications::find($id); if ($data->is_read == 0) { $data->is_read = 1; $data->save(); } return View::make('organisation.read_message')->with('data', $data); }
/** * Upload a new document. * * @author Kuldeep Dangi <*****@*****.**> */ public function actionUpload() { //name,category_id,images,description,price,userid, $model = new Extensions(); if (!empty($_POST['user_id'])) { $userModel = Users::model()->findByPk($_POST['user_id']); if ($userModel) { $model->attributes = $_POST; $uploadedFiles = CUploadedFile::getInstancesByName('images'); if ($uploadedFiles && count($uploadedFiles) > 0) { $allUploadedFiles = array(); foreach ($uploadedFiles as $uploadedFile) { $fileName = strtotime($this->getCurrentDateTime()) . '-' . $uploadedFile; $uploadedFile->saveAs(Yii::app()->basePath . '/../../' . Extensions::FILE_UPLOAD_PATH . $fileName); $allUploadedFiles[] = $fileName; } $savedFileNames = $model->getPdfFromImages($allUploadedFiles); $model->pdf = Extensions::FILE_CONVERT_PATH . $savedFileNames['pdf']; $model->imagepdf = $savedFileNames['imagepdf']; $model->image = Extensions::FILE_IMAGE_PATH . $savedFileNames['image']; if ($model->save()) { //Update Reward points // $userModel->rewardpoints = $userModel->rewardpoints + // self::REWARD_ON_NOTE_UPLOAD; // $userModel->save(); $nCash = new Ncash(); $nCash->addAmount($userObj->user_id, self::REWARD_ON_NOTE_UPLOAD, 2); $notficationModel = new Notifications(); $notficationModel->sendPushNotification(array('deviceToken' => $userModel->deviceToken, 'deviceType' => $userModel->deviceType, 'message' => 2)); $this->result['success'] = true; } else { $this->result['message'] = 'Record save failed.'; } } else { $this->result['message'] = 'No images to save'; } } else { $this->result['message'] = 'User does not exist.'; } } else { $this->result['message'] = 'Invalid user id.'; } $this->sendResponse($this->result); }
public static function addHook($hookpoint, $hook) { Hooks::$hooks[$hookpoint][] = $hook; if ($hook['class']) { $log = $hook['class'] . '::'; } $log .= $hook['function'] . '('; $log .= implode(', ', $hook['params']) . ')'; Notifications::addLog("Hook {$log} added to {$hookpoint}", 'Hooks'); }
private function handleInProductionMode(Request $request, Exception $e) { if ($this->isQueryException($e)) { \Notifications::add('Update not allowed', 'danger', '0'); return redirect()->back(); } if ($request->ajax() || $request->wantsJson()) { return new JsonResponse([$this->getStatusCode($e) . ': ' . $e->getMessage()], $this->getStatusCode($e)); } return response()->view('errors.500', ['exception' => $e], $this->getStatusCode($e)); }
function xoops_module_pre_uninstall_notifications(&$module) { $xoops = Xoops::getInstance(); XoopsLoad::loadFile($xoops->path('modules/notifications/class/helper.php')); $helper = Notifications::getInstance(); $plugins = \Xoops\Module\Plugin::getPlugins('notifications'); foreach (array_keys($plugins) as $dirname) { $helper->deleteModuleRelations($xoops->getModuleByDirname($dirname)); } return true; }
public function pushNotifications() { $notifications = $this->notifications->all(); foreach ($notifications as $notification) { $subscriptionId = $notification['subscription_id']; $subscriber = $this->subscriptions->getById($subscriptionId); if (is_null($subscriber)) { $this->log("Unknown subscriber: {$subscriptionId}"); $this->subscriptions->deleteById($subscriptionId); $this->notifications->deleteById($notification['id']); continue; } $notData = array_merge($notification, $subscriber, array('notificationId' => $notification['id'])); if ($this->push($notData)) { $this->notifications->deleteById($notification['id']); } else { $notification_json = json_encode($notData); $this->log("Pushing notification failed: {$notification_json}"); } } }
public function afterDelete() { parent::afterDelete(); $shared = Shared::model()->findAllByAttributes(array('cam_id' => $this->id)); foreach ($shared as $s) { Notifications::model()->deleteAllByAttributes(array('shared_id' => $s->id, 'status' => 1)); $s->delete(); } Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id)); Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id . '_low')); return true; }
/** * @url GET logout */ public function logout() { try { $session = Session::singleton(); $db = Database::singleton(); $db->deleteAtom(session_id(), 'SESSION'); $db->closeTransaction('Logout successfull', false, true, false); return array('notifications' => Notifications::getAll()); } catch (Exception $e) { throw new RestException($e->getCode(), $e->getMessage()); } }