Example #1
0
 public function edit($id = 0)
 {
     $obj = new User();
     $obj->get_by_id((int) $id);
     $testid = $this->session->userdata('testid');
     $test = new Test();
     $test->get_by_id($testid);
     if (!$_POST) {
         echo $obj->to_json();
     } else {
         if (isset($_POST['model']) and $model = $_POST['model']) {
             $obj->from_json($model);
             if ($obj->save()) {
                 $test->save($obj);
                 //保存关系
                 echo $obj->to_json();
             } else {
                 echo json_encode(array('error' => $obj->error->string));
             }
         } else {
             if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
                 $test->delete($obj);
                 $obj->delete();
             }
         }
     }
 }
    public function action_comment_insert_after($comment)
    {
        // we should only execute on comments, not pingbacks
        // and don't bother if the comment is know to be spam
        if ($comment->type != Comment::COMMENT || $comment->status == Comment::STATUS_SPAM) {
            return;
        }
        $post = Post::get(array('id' => $comment->post_id));
        $author = User::get_by_id($post->user_id);
        $status = $comment->status == Comment::STATUS_UNAPPROVED ? ' UNAPPROVED' : ' approved';
        $title = sprintf(_t('[%1$s] New%3$s comment on: %2$s'), Options::get('title'), $post->title, $status);
        $message = <<<MESSAGE
The following comment was added to the post "%1\$s".
%2\$s

Author: %3\$s <%4\$s>
URL: %5\$s

%6\$s

-----
Moderate comments: %7\$s
MESSAGE;
        $message = _t($message);
        $message = sprintf($message, $post->title, $post->permalink, $comment->name, $comment->email, $comment->url, $comment->content, URL::get('admin', 'page=comments'));
        $headers = array('MIME-Version: 1.0', 'Content-type: text/plain; charset=utf-8', 'Content-Transfer-Encoding: 8bit', 'From: ' . $this->mh_utf8($comment->name) . ' <' . $comment->email . '>');
        mail($author->email, $this->mh_utf8($title), $message, implode("\r\n", $headers));
    }
Example #3
0
 function view($id = null)
 {
     if (is_null($id)) {
         echo "error: no id supplied";
         return false;
     }
     $this->load->library('bitly');
     $this->form_validation->set_rules('name', 'Task Name', 'required|trim');
     $data = array();
     $docket = new Docket();
     $task = new Task();
     $user = new User();
     if (!$docket->where('shared', 1)->where('id', $id)->count()) {
         redirect('dockets');
     } else {
         $data['docket'] = $docket->get_by_id($id);
     }
     if ($docket->short_url == '') {
         $docket->short_url = $this->bitly->shorten(base_url() . 'index.php/pub/view/' . $docket->id);
         $docket->save();
     }
     if ($task->where('completed', 0)->where_related_docket('id', $docket->id)->count() == 0) {
         $data['pending_tasks'] = array();
     } else {
         $data['pending_tasks'] = $task->where('completed', 0)->where_related_docket('id', $docket->id)->get()->all;
     }
     if ($task->where('completed', 1)->where_related_docket('id', $docket->id)->count() == 0) {
         $data['completed_tasks'] = array();
     } else {
         $data['completed_tasks'] = $task->where('completed', 1)->where_related_docket('id', $docket->id)->get()->all;
     }
     $data['user'] = $user->get_by_id($docket->user_id);
     $this->load->view('pub/view', $data);
 }
Example #4
0
 public function select_designer($order_id, $designer_id = null)
 {
     import('system/share/network/redirect');
     $smarty = parent::load('smarty');
     $order = Order::get_by_id($order_id);
     if ($order->Customer->CustomerUser->id != User::info('id')) {
         $message = sprintf('这个订单不是您的');
         HTTPRedirect::flash_to('', $message, $smarty, 'cus_flash_to');
     }
     $workflow = Workflow::get_by_alias('首页设计');
     $designer_id = abs(intval($designer_id));
     if ($designer_id) {
         $designer = User::get_by_id($designer_id);
     } else {
         $smarty->assign('page_title', '选择设计师');
         /*
          * 这里可能对设计师的列表有一个条件
          */
         $smarty->assign('order', $order);
         $smarty->assign('designer', User::get_by_role_alias('设计师'));
     }
     if ($designer_id && $designer) {
         $order->Workflow = $workflow;
         $order->Designer = $designer;
         $order->save();
         $message = sprintf('首页设计任务已经成功分配给 %s', $designer->name);
         HTTPRedirect::flash_to('customer', $message, $smarty, 'cus_flash_to');
     } else {
         $smarty->display('customer/select_designer');
     }
 }
Example #5
0
 function addUserTest($id)
 {
     $t = new Test();
     $t->get_by_id($id);
     $u = new User();
     $u->get_by_id(1);
     $u->save($t);
 }
Example #6
0
 public function filter_url_args($args, $post)
 {
     if ($post instanceof Post && $post->typename == 'proposal') {
         $client_user = User::get_by_id($post->info->client_contact);
         $client = Post::get(array('id' => $client_user->info->client, 'ignore_permissions' => true));
         $args['client_slug'] = $client->slug;
     }
     return $args;
 }
Example #7
0
function userCache_get($key)
{
    if (array_key_exists($key, $GLOBALS['USER'])) {
        return $GLOBALS['USER'][$key];
    }
    $user = User::get_by_id($key);
    $GLOBALS['USER'][$key] = $user;
    return $user;
}
Example #8
0
 function remove()
 {
     $user = User::get_by_id($_SESSION['user_id']);
     if ($user->deauthenticate() == TRUE) {
         Application::flash('info', 'You are now logged out.');
         Application::redirect_to('items');
     } else {
         Application::flash('info', 'Nothing to see here.');
         $this->loadView();
     }
 }
Example #9
0
 function add()
 {
     $user = User::get_by_id($_SESSION['user_id']);
     $_POST['email'] = trim($_POST['email']);
     $error = '';
     if ($_POST['email'] == '') {
         $error .= 'Please enter an email address.<br />';
     }
     if ($user->invites < 1) {
         $error .= 'You don\'t have any invites remaining.<br />';
     }
     // Check if email contains spaces
     if (User::check_contains_spaces($_POST['email']) == TRUE) {
         $error .= 'Email address cannot contain spaces.<br />';
     }
     if (User::check_contains_at($_POST['email']) != TRUE) {
         $error .= 'Email must contain an @ symbol.<br />';
     }
     // Check if already invited
     if (Invite::check_invited($_SESSION['user_id'], $_POST['email']) == TRUE) {
         $error .= 'You have already invited this person.<br />';
     }
     // Check if already a user
     if (is_object(User::get_by_email($_POST['email'])) == TRUE) {
         $error .= 'This person is already using ' . $this->config->name . '!<br />';
     }
     if ($error == '') {
         // No problems so do signup + login
         // Add invite to database
         $id = Invite::add($_SESSION['user_id'], $_POST['email']);
         // Decrement invites in users table
         $user->update_invites(-1);
         // Award points
         if (isset($this->plugins->points)) {
             $this->plugins->points->update($_SESSION['user_id'], $this->plugins->points['per_invite_sent']);
         }
         // Log invite
         if (isset($this->plugins->log)) {
             $this->plugins->log->add($_SESSION['user_id'], 'invite', $id, 'add', $_POST['email']);
         }
         $admin = User::get_by_id($this->config->admin_users[0]);
         $to = array('email' => $_POST['email']);
         $subject = '[' . $this->config->name . '] An invitation from ' . $user->username;
         $link = $this->config->url . 'signup/' . $id;
         $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/invite_friend.html"), array('user' => $user, 'link' => $link, 'app' => $this));
         // Email user
         $this->email->send_email($to, $subject, $body);
         Application::flash('success', 'Invite sent!');
     } else {
         $this->uri['params']['email'] = $_POST['email'];
         Application::flash('error', $error);
     }
     $this->index();
 }
Example #10
0
 function get_amount($user_id)
 {
     $user = new User();
     $gold = new gold();
     if ($user->where('id', $user_id)->count() == 0) {
         return false;
     }
     $user->get_by_id($user_id);
     $gold->where_related_user('id', $user->id)->get();
     return $gold->amount;
 }
Example #11
0
 function show($name)
 {
     $content = '';
     if ($name == 'about') {
         $authors = '';
         foreach ($this->config->admin_users as $value) {
             $author = User::get_by_id($value);
             if ($this->config->private != TRUE || isset($_SESSION['user_id'])) {
                 $authors .= $this->get_link_to($author->username, 'users', 'show', $author->id) . ', ';
             } else {
                 $authors .= $author->username . ', ';
             }
         }
         $authors = substr($authors, 0, -2);
         $content = '<p>' . $this->config->name . ' is a web app created by ' . $authors . ' based on the <a href="http://github.com/DHS/rat">rat</a> framework. ';
         if ($this->config->beta == TRUE) {
             $content .= 'It is currently in beta.';
         }
         $content .= "</p>\n";
         $content .= '<p>It lets you create ' . $this->config->items->name_plural;
         if ($this->config->items->titles->enabled == TRUE) {
             $content .= ' with ' . strtolower($this->config->items->titles->name_plural);
         }
         if ($this->config->items->comments->enabled == TRUE || $this->config->items->likes->enabled == TRUE) {
             $content .= ' and then ';
             if ($this->config->items->comments->enabled == TRUE) {
                 $content .= ' add ' . strtolower($this->config->items->comments->name_plural) . ' ';
             }
             if ($this->config->items->comments->enabled == TRUE && $this->config->items->likes->enabled == TRUE) {
                 $content .= ' and ';
             }
             if ($this->config->items->likes->enabled == TRUE) {
                 $content .= " '" . strtolower($this->config->items->likes->name) . "' ";
             }
             $content .= 'them';
         }
         $content .= ". </p>\n";
         if ($this->config->invites->enabled == TRUE) {
             $content .= "<p>It also has an invite system so that you can invite your friends.</p>\n";
         }
         if (isset($this->plugins->points)) {
             $content .= '<p>It also has a points system';
             if ($this->plugins->points['leaderboard'] == TRUE) {
                 $content .= ' and a leaderboard so you can see how you\'re doing relative to everyone else';
             }
             $content .= ".</p>\n";
         }
         if (isset($this->plugins->gravatar)) {
             $content .= '<p>' . $this->config->name . ' is <a href="http://gravatar.com/">Gravatar</a>-enabled.</p>' . "\n";
         }
     }
     $this->loadView('pages/' . $name, array('title' => ucfirst($name), 'content' => $content));
 }
Example #12
0
 public static function mapDefinitionArray($definitionArray)
 {
     if (empty($definitionArray)) {
         return array();
     }
     $results = array();
     $defIds = array();
     $sourceIds = array();
     $userIds = array();
     foreach ($definitionArray as $definition) {
         $defIds[] = $definition->id;
         $sourceIds[] = $definition->sourceId;
         $userIds[] = $definition->userId;
     }
     $userMap = self::mapById(Model::factory('User')->where_in('id', array_unique($userIds))->find_many());
     $sourceMap = self::mapById(Model::factory('Source')->where_in('id', array_unique($sourceIds))->find_many());
     foreach ($definitionArray as $definition) {
         $result = new SearchResult();
         $result->definition = $definition;
         $result->user = $userMap[$definition->userId];
         $result->source = $sourceMap[$definition->sourceId];
         $result->typos = array();
         $result->comment = null;
         $result->wotd = false;
         $result->bookmark = false;
         $results[$definition->id] = $result;
     }
     $typos = Model::factory('Typo')->where_in('definitionId', $defIds)->find_many();
     foreach ($typos as $t) {
         $results[$t->definitionId]->typos[] = $t;
     }
     $comments = Model::factory('Comment')->where_in('definitionId', $defIds)->where('status', ST_ACTIVE)->find_many();
     foreach ($comments as $c) {
         $results[$c->definitionId]->comment = $c;
         // We still run one query per comment author, but there are very few comments
         $results[$c->definitionId]->commentAuthor = User::get_by_id($c->userId);
     }
     if ($suid = session_getUserId()) {
         $defIdString = implode(',', $defIds);
         // This actually requires a stronger condition: that the user has PRIV_WOTD privileges; but that check would require a DB hit.
         // So we check that the user is logged in, which is cheap. The admin permission is checked in the template.
         $wotdStatuses = ORM::for_table('WordOfTheDay')->raw_query("select R.refId, W.displayDate from WordOfTheDay W join WordOfTheDayRel R on W.id = R.wotdId " . "where R.refId in ({$defIdString}) and refType = 'Definition'")->find_many();
         foreach ($wotdStatuses as $w) {
             $results[$w->refId]->wotd = $w->displayDate ? $w->displayDate : true;
         }
         $bookmarks = Model::factory('UserWordBookmark')->where('userId', $suid)->where_in('definitionId', $defIds)->find_many();
         foreach ($bookmarks as $b) {
             $results[$b->definitionId]->bookmark = true;
         }
     }
     return $results;
 }
Example #13
0
 public function theme_route_change_sudo()
 {
     $form = $this->get_form();
     $user_id = $form->userlist->value;
     $user = User::get_by_id($user_id);
     if ($_SESSION['user_id'] == $user->id) {
         unset($_SESSION['sudo']);
     } else {
         $_SESSION['sudo'] = $user->id;
     }
     $ar = new AjaxResponse(200, 'Ok.');
     $ar->html('#sudo_handle', $user->displayname);
     $ar->out();
 }
 /**
  * React to the update of a post status to 'published'
  * @param Post $post The post object with the status change
  * @param int $oldvalue The old status value
  * @param int $newvalue The new status value
  **/
 public function action_post_update_status($post, $oldvalue, $newvalue)
 {
     if (is_null($oldvalue)) {
         return;
     }
     if ($newvalue == Post::status('published') && $post->content_type == Post::type('entry') && $newvalue != $oldvalue) {
         $user = User::get_by_id($post->user_id);
         if (!empty($user->info->statusnet_name) && !empty($user->info->statusnet_pass)) {
             $name = $user->info->statusnet_name;
             $pw = $user->info->statusnet_pass;
             $svcurl = 'https://' . $user->info->statusnet_svc . '/api/statuses/update.xml';
             $this->post_status($svcurl, $user->info->statusnet_prefix . $post->title . ' ' . $post->permalink, $name, $pw);
         }
     }
 }
Example #15
0
 /**
  * This function is executed when the filter "before_post_delete" is
  * called just before a post is to be deleted.
  * This filter should return a boolean value to indicate whether
  * the post should be deleted or not.
  * @param Boolean Whether to delete the post or not
  * @param Post The post object to potentially delete
  * @return Boolean Whether to delete the post or not
  **/
 function filter_post_delete_allow($result, $post)
 {
     // all we need to do is set the post status to "deleted"
     // and then return false.  The Post::delete() method will
     // see the false return value, and simply return, leaving
     // the post in the database.
     if ($post->status != Post::status('deleted') && is_object(User::get_by_id($post->user_id))) {
         $post->info->prior_status = $post->status;
         $post->status = Post::status('deleted');
         $post->update();
         return false;
     } else {
         return true;
     }
 }
Example #16
0
   function view()
   {
       // View the log
       global $mysqli;
       $sql = "SELECT * FROM log ORDER BY id DESC LIMIT 10";
       $query = mysqli_query($mysqli, $sql);
       $entries = array();
       while ($entry = mysqli_fetch_assoc($query)) {
           $entry['user'] = User::get_by_id($entry['user_id']);
           $entries[] = $entry;
       }
       if (is_array($entries)) {
           // Debuggage
           //echo '<pre>';
           //var_dump($entries);
           //echo '</pre>';
           $return = '<table class="table table-striped">
 <thead>
   <tr>
     <th>User</th>
     <th>Object</th>
     <th>Action</th>
     <th>Params</th>
     <th>Timestamp</th>
   </tr>
 </thead>
 <tbody>';
           foreach ($entries as $entry) {
               $return .= '<tr><td>';
               if ($entry['user']->username != NULL) {
                   $return .= $this->get_link_to($entry['user']->username, 'users', 'show', $entry['user']->id);
               }
               $return .= '</td><td>';
               $return .= $entry['object_type'];
               $return .= '</td><td>';
               $return .= $entry['action'];
               $return .= '</td><td>';
               if ($entry['params'] != NULL) {
                   $return .= $entry['params'];
               }
               $return .= '</td><td>' . $entry['date'] . '</td></tr>';
           }
           $return .= '</tbody></table>';
           return $return;
       }
   }
Example #17
0
 function view($id = null)
 {
     if (is_null($id)) {
         echo "error: no id supplied";
         return false;
     }
     $this->load->library('bitly');
     $this->form_validation->set_rules('name', 'Task Name', 'required|trim|callback_check_task');
     $this->form_validation->set_rules('due', 'Due Date', 'trim|valid_date[d-m-y,-]');
     $data = array();
     $docket = new Docket();
     $task = new Task();
     $user = new User();
     $user->get_by_id($this->dx_auth->get_user_id());
     $data['gold_amount'] = $this->treasure->get_amount($this->dx_auth->get_user_id());
     if (!$docket->where('user_id', $this->dx_auth->get_user_id())->where('id', $id)->count()) {
         redirect('dockets');
     } else {
         $data['docket'] = $docket->where('user_id', $this->dx_auth->get_user_id())->get_by_id($id);
     }
     if ($docket->short_url == '') {
         $docket->short_url = $this->bitly->shorten(base_url() . 'index.php/pub/view/' . $docket->id);
         $docket->save();
     }
     if ($this->form_validation->run() == false) {
     } else {
         $data['pending_tasks'] = array();
         $task->name = $this->input->post('name');
         $task->due = date("Y-m-d", strtotime($this->input->post('due')));
         $task->save(array($docket, $user));
         $docket->completed = 0;
         $docket->save();
     }
     if ($task->where('completed', 0)->where_related_docket('id', $docket->id)->count() == 0) {
         $data['pending_tasks'] = array();
     } else {
         $data['pending_tasks'] = $task->where('completed', 0)->where_related_docket('id', $docket->id)->get()->all;
     }
     if ($task->where('completed', 1)->where_related_docket('id', $docket->id)->count() == 0) {
         $data['completed_tasks'] = array();
     } else {
         $data['completed_tasks'] = $task->where('completed', 1)->where_related_docket('id', $docket->id)->get()->all;
     }
     $this->load->view('dockets/view', $data);
 }
Example #18
0
 public static function get_by_id($id)
 {
     global $mysqli;
     $config = new Config();
     $id = sanitize_input($id);
     $sql = "SELECT `id`, `user_id`, `item_id`, `content`, `date` FROM `{$config->database->{$config->site_identifier}->prefix}comments` WHERE `id` = {$id}";
     $query = mysqli_query($mysqli, $sql);
     $result = mysqli_fetch_assoc($query);
     if (!is_array($result)) {
         // Comment not found
         return null;
     } else {
         $comment = new Comment($result);
         $comment->user = User::get_by_id($result['user_id']);
         unset($comment->user->password);
         return $comment;
     }
 }
Example #19
0
 function atom($id)
 {
     if ($id == '') {
         echo 'No Feed exists at this address';
         return;
     }
     $docket = new Docket();
     $task = new Task();
     $user = new User();
     $data['docket'] = $docket->get_by_id($id);
     if ($docket->shared == 0) {
         echo 'No Feed exists at this address';
         return;
     }
     $data['tasks'] = $task->where('docket_id', $docket->id)->get()->all;
     $data['author_name'] = $user->get_by_id($docket->user_id);
     $this->load->view('feed/atom', $data);
 }
Example #20
0
function session_loadUserFromCookie()
{
    if (!isset($_COOKIE['prefs']) || !isset($_COOKIE['prefs']['lll'])) {
        return;
    }
    $cookie = Cookie::get_by_cookieString($_COOKIE['prefs']['lll']);
    $user = $cookie ? User::get_by_id($cookie->userId) : null;
    if ($user && $user->identity) {
        session_setVariable('user', $user);
    } else {
        // The cookie is invalid or this account doesn't have an OpenID identity yet.
        setcookie("prefs[lll]", NULL, time() - 3600, '/');
        unset($_COOKIE['prefs']['lll']);
        if ($cookie) {
            $cookie->delete();
        }
    }
}
Example #21
0
 public function send_email($to, $subject, $body, $debug = FALSE)
 {
     if ($this->app->config->send_emails == TRUE) {
         $admin = User::get_by_id($this->app->config->admin_users[0]);
         if (isset($to['name'])) {
             $to = "{$to['name']} <{$to['email']}>";
         } elseif (isset($to['email'])) {
             $to = $to['email'];
         }
         $headers = "From: {$this->app->config->send_emails_from}\r\nBcc: {$admin->email}\r\nContent-type: text/html\r\n";
         if ($debug == TRUE) {
             $to = htmlentities($to);
             echo "{$to}<br />{$subject}<br />{$body}<br />{$headers}";
             exit;
         } else {
             mail($to, $subject, $body, $headers);
         }
     }
 }
Example #22
0
 public static function get_by_user_item($user_id, $item_id)
 {
     global $mysqli;
     $config = new Config();
     $user_id = sanitize_input($user_id);
     $item_id = sanitize_input($item_id);
     $sql = "SELECT `id` FROM `{$config->database->{$config->site_identifier}->prefix}likes` WHERE `user_id` = {$user_id} AND `item_id` = {$item_id}";
     $query = mysqli_query($mysqli, $sql);
     $result = mysqli_fetch_assoc($query);
     $id = $result['id'];
     if ($result == FALSE) {
         return $null;
     } else {
         $like = Like::get_by_id($id);
         $like->user = User::get_by_id($user_id);
         unset($like->user->password);
         return $like;
     }
 }
Example #23
0
 function get_user()
 {
     if (is_null($this->logged_in_user)) {
         if (!$this->CI->db->table_exists('users')) {
             return FALSE;
         }
         $id = $this->session->userdata('logged_in_id');
         if (is_numeric($id)) {
             $u = new User();
             $u->get_by_id($id);
             if ($u->exists()) {
                 $u->group->get();
                 $this->logged_in_user = $u;
                 return $this->logged_in_user;
             }
         }
         return FALSE;
     } else {
         return $this->logged_in_user;
     }
 }
Example #24
0
 function invite()
 {
     $user = User::get_by_id($_SESSION['user_id']);
     $email = $_POST['email'];
     if ($email != '') {
         // Add invite to database
         $id = Invite::add($_SESSION['user_id'], $email);
         // Log invite
         if (isset($this->plugins->log)) {
             $this->plugins->log->add($_SESSION['user_id'], 'invite', $id, 'admin_add', $email);
         }
         // Load template into $body variable
         $to = array('email' => $email);
         $subject = '[' . $this->config->name . '] Your ' . $this->config->name . ' invite is here!';
         $link = $this->config->url . 'users/add/' . $id . '/?email=' . urlencode($email);
         $body = $this->twig_string->render(file_get_contents("themes/{$this->config->theme}/emails/admin_invite.html"), array('link' => $link, 'app' => $this));
         // Email user
         $this->email->send_email($to, $subject, $body);
         Application::flash('success', 'User invited!');
     }
     $this->signups();
 }
Example #25
0
 function remove($friend_id)
 {
     $user = User::get_by_id($_SESSION['user_id']);
     $friend = User::get_by_id($friend_id);
     // Check that frienship is legit
     if ($friend->friend_check($_SESSION['user_id']) == TRUE) {
         // Remove friendship
         $user->friend_remove($friend_id);
         // Log parting of ways
         if (isset($this->plugins->log)) {
             $this->plugins->log->add($user->id, 'friend', $friend_id, 'remove');
         }
     }
     $session['user_id'] = $_SESSION['user_id'];
     $friends = FALSE;
     $this->user = $friend;
     // Copying the work of loadView
     $params = array('app' => $this, 'session' => $_SESSION);
     $params['session'] = $session;
     $params['user'] = $friend;
     $params['friends'] = $friends;
     echo $this->twig->render("partials/friend.html", $params);
 }
Example #26
0
<?php

require_once "header.php";
if (isset($_GET['id'])) {
    $object = Store::get_by_id($_GET['id']);
} else {
    header("location: index.php?negative");
}
if (!$session->is_logged_in()) {
    header("location: index.php?negative");
} else {
    $loggeduser = User::get_by_id($session->userid);
    if ($loggeduser->enabled == DISABLED) {
        header("location: index.php?disabled");
    }
}
$pathinfo = pathinfo($_SERVER["PHP_SELF"]);
$basename = $pathinfo["basename"];
$currentFile = str_replace(".php", "", $basename);
?>

<div class="container-fluid">
<div class="row-fluid">
  <div class="span1"></div>
  <div class="span9">
    <form id="theform" class="form-horizontal" action="#" method="post" enctype="multipart/form-data">
      <fieldset>
      <legend>
        Update
      </legend>
Example #27
0
	/**
	 * private function get_author()
	 * returns a User object for the author of this post
	 * @return User a User object for the author of the current post
	 */
	private function get_author()
	{
		if ( ! isset( $this->author_object ) ) {
			// XXX for some reason, user_id is a string sometimes?
			$this->author_object = User::get_by_id( $this->user_id );
		}
		return $this->author_object;
	}
    /**
     * Send the email notifications for comments
     */
    private function send_comment_notifications($comment)
    {
        // we should only execute on comments, not pingbacks
        // and don't bother if the comment is know to be spam
        if ($comment->type != Comment::COMMENT || $comment->status == Comment::STATUS_SPAM) {
            return;
        }
        $post = Post::get(array('id' => $comment->post_id));
        $author = User::get_by_id($post->user_id);
        $title = sprintf(_t('[%1$s] New comment on: %2$s', 'notify_all'), Options::get('title'), $post->title);
        $message = <<<MESSAGE
There is a new comment on the post "%1\$s", on %2\$s:
%3\$s

Author: %4\$s <%5\$s>
URL: %6\$s

Comment:

MESSAGE;
        $message = _t($message, 'notify_all');
        $message = sprintf($message, $post->title, Options::get('title'), $post->permalink . '#comment-' . $comment->id, $comment->name, $comment->email, $comment->url);
        $body = $comment->content;
        $headers = 'From: ' . $comment->name . ' <' . $comment->email . '>';
        $users = Users::get();
        foreach ($users as $user) {
            // if user is not allowed to override, and email notification for comments is on, send email
            // if user is allowed to override, and they have opted to receive emails, send email
            // also don't send email to the email address of the person who wrote the comment
            if ((!Options::get('notify_all__user_can_override') && Options::get('notify_all__notify_comments') || Options::get('notify_all__user_can_override') && $user->info->notify_all__notify_comments) && $user->email != $comment->email) {
                $this->send_mail($user->email, $title, $message, $body, $headers, 'comment');
            }
        }
    }
Example #29
0
<!--SCRIPTS-->
<script src="public/jqueryui/js/jquery-1.9.1.js"></script>
<script src="public/jqueryui/js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="public/js/i18n/grid.locale-en.js"></script>
<script src="public/js/jquery.jqGrid.min.js"></script>
<!--STYLES-->
<link rel="stylesheet" href="public/jqueryui/css/smoothness/jquery-ui-1.10.3.custom.min.css" />
<link href="public/css/ui.jqgrid.css" rel="stylesheet" media="screen" />

<script>

  var isSuperAdmin = "<?php 
echo User::get_by_id($session->user_id)->is_super_admin();
?>
";

  if(isSuperAdmin)
  {
    isSuperAdmin = true;
  }
  else
  {
    isSuperAdmin = false;
  }  

  $(function()
  {
    var last_clicked_id = 0;
    var lastSel = 0;

    function accessFormat( cellvalue, options, rowObject )
Example #30
0
    $limit = " LIMIT " . $_GET['limit'] . " ";
}
if (isset($_GET['sortby']) && isset($_GET['sortorder'])) {
    $sort = " ORDER BY " . $_GET['sortby'] . " " . $_GET['sortorder'] . " ";
}
if (isset($_GET['sortby']) && !isset($_GET['sortorder'])) {
    $sort = " ORDER BY " . $_GET['sortby'] . $sortorder . " ";
}
//======================================================
$items = Review::get_by_sql("SELECT * FROM " . T_REVIEWS . " WHERE " . $where . $sort . $limit);
$filename = 0;
if (!isset($_GET['blob'])) {
    foreach ($items as $item) {
        $filename++;
        $random = rand(0, 1);
        $user = User::get_by_id($item->userid);
        $item->username = $user->get_full_name();
        file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($user->picture));
        $item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg";
    }
}
echo str_replace('\\/', '/', json_encode($items));
//echo json_encode($items, JSON_UNESCAPED_SLASHES);
function equallike($field, $type)
{
    $string = "";
    if ($type == "string") {
        if (isset($_GET['equal'])) {
            $string = " = '" . $field . "'";
        } else {
            $string = " LIKE '%" . $field . "%'";