Example #1
0
 public function buildLinks($fileid)
 {
     $user = new Users();
     $rowSetUsers = $this->getLinkOnAvatar($fileid);
     foreach ($rowSetUsers as $rowUser) {
         $user->set($rowUser);
         Sydney_Search_Files_Result::init($user->getModule(), 'Avatar', $user->get()->id);
         Sydney_Search_Files_Result::add('label', $user->__toString());
         Sydney_Search_Files_Result::add('link', '/adminpeople/index/editindex/id/' . $user->get()->id);
     }
 }
 /**
  * Handles get requests for the dashboard
  * @todo update check should probably be cron'd and cached, not re-checked every load
  */
 public function get_dashboard()
 {
     // Not sure how best to determine this yet, maybe set an option on install, maybe do this:
     $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
     $this->theme->active_time = HabariDateTime::date_create($firstpostdate);
     // get the active theme, so we can check it
     // @todo this should be worked into the main Update::check() code for registering beacons
     $active_theme = Themes::get_active();
     $active_theme = $active_theme->name . ':' . $active_theme->version;
     // check to see if we have updates to display
     $this->theme->updates = Options::get('updates_available', array());
     // collect all the stats we display on the dashboard
     $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
     $this->fetch_dashboard_modules();
     // check for first run
     $u = User::identify();
     if (!isset($u->info->experience_level)) {
         $this->theme->first_run = true;
         $u->info->experience_level = 'user';
         $u->info->commit();
     } else {
         $this->theme->first_run = false;
     }
     $this->display('dashboard');
 }
Example #3
0
 /**
  * Handles get requests for the dashboard
  * @todo update check should probably be cron'd and cached, not re-checked every load
  */
 public function get_dashboard()
 {
     // Not sure how best to determine this yet, maybe set an option on install, maybe do this:
     $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
     if ($firstpostdate) {
         $this->theme->active_time = DateTime::create($firstpostdate);
     }
     // check to see if we have updates to display
     $this->theme->updates = Options::get('updates_available', array());
     // collect all the stats we display on the dashboard
     $user = User::identify();
     $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'post_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total('approved', false), 'tag_count' => Tags::vocabulary()->count_total(), 'user_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('draft'), 'user_id' => $user->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total('unapproved', false) : Comments::count_by_author(User::identify()->id, Comment::status('unapproved')), 'spam_comment_count' => $user->can('manage_all_comments') ? Comments::count_total('spam', false) : Comments::count_by_author($user->id, Comment::status('spam')), 'user_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => $user->id)));
     // check for first run
     $u = User::identify();
     $uinfo = $u->info;
     if (!isset($uinfo->experience_level)) {
         $this->theme->first_run = true;
         $u->info->experience_level = 'user';
         $u->info->commit();
     } else {
         $this->theme->first_run = false;
     }
     $this->get_additem_form();
     Stack::add('admin_header_javascript', 'dashboard-js');
     $this->display('dashboard');
 }
Example #4
0
 public static function get_user()
 {
     if (is_null(self::$user_object)) {
         self::$user_object = Users::get(self::$data["username"]);
     }
     return self::$user_object;
 }
Example #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = Users::get();
     $comments = Comments::get();
     $supports = Supports::get();
     $notes = Notes::get();
     $usersJson = array();
     $commentsJson = array();
     $supportsJson = array();
     $notesJson = array();
     // build users
     foreach ($users as $user) {
         array_push($usersJson, array('id' => $user->id, 'name' => $user->name));
     }
     // build comments
     foreach ($comments as $comment) {
         array_push($commentsJson, array('id' => $comment->id, 'article_id' => $comment->article_id, 'user_id' => $comment->user_id, 'comment' => $comment->comment, 'challenge' => $comment->challenge));
     }
     // build supports
     foreach ($supports as $support) {
         array_push($supportsJson, array('id' => $support->id, 'user_id' => $support->user_id, 'comment_id' => $support->comment_id));
     }
     // build notes
     foreach ($notes as $note) {
         array_push($notesJson, array('id' => $note->id, 'comment_id' => $note->comment_id, 'comment' => $note->comment));
     }
     // build json
     $json = array('users' => $usersJson, 'comments' => $commentsJson, 'supports' => $supportsJson, 'notes' => $notesJson);
     // display json
     echo json_encode($json);
 }
Example #6
0
 public function action_handler_display_user($params)
 {
     $users = Users::get(array('info' => array('ircnick' => $params['username'])));
     //Utils::debug($user->info);
     switch (count($users)) {
         case 0:
             $xml = new SimpleXMLElement('<error>No user with that IRC nickname.</error>');
             break;
         default:
             $xml = new SimpleXMLElement('<error>More than one user is registered under that nickname!</error>');
             break;
         case 1:
             $user = reset($users);
             $xml = new SimpleXMLElement('<userinfo></userinfo>');
             $xml['nickname'] = $params['username'];
             $xml->blog = $user->info->blog;
             $xml->name = $user->info->displayname;
             $xml->nickname = $user->info->ircnick;
             break;
     }
     header('Content-type: text/xml');
     ob_clean();
     // no idea why we get a blank line at the beginning, but it breaks XML parsing
     echo $xml->asXML();
 }
Example #7
0
 public function pdoEditModelAction($id)
 {
     $this->_view->title = 'Model Edit Form';
     $this->_view->link = base_url() . 'pdo-database/pdo-model/pdo-edit-model/' . $id;
     $users = new Users();
     $row = $users->get($id);
     if (empty($row)) {
         redirect('pdo-database/pdo-model/pdo-model');
     }
     $this->_view->data = $row;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (sizeof($val->errors) == 0) {
             $data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'address' => $_POST['address']);
             $users->update($id, $data);
             redirect('pdo-database/pdo-model/pdo-model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('pdo-database/pdo-model/_form');
 }
function countStats()
{
    $resultData = array();
    $today = date('Y-m-d');
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post"));
    $resultData['post']['total'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where DATE(date_added)='{$today}'"));
    $resultData['post']['today'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='1'"));
    $resultData['post']['published'] = $loadData[0]['totalcount'];
    $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='0'"));
    $resultData['post']['pending'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments"));
    $resultData['comments']['total'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where DATE(date_added)='{$today}'"));
    $resultData['comments']['today'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='1'"));
    $resultData['comments']['approved'] = $loadData[0]['totalcount'];
    $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='0'"));
    $resultData['comments']['pending'] = $loadData[0]['totalcount'];
    $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus"));
    $resultData['contactus']['total'] = $loadData[0]['totalcount'];
    $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus where DATE(date_added)='{$today}'"));
    $resultData['contactus']['today'] = $loadData[0]['totalcount'];
    $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users"));
    $resultData['users']['total'] = $loadData[0]['totalcount'];
    $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users where DATE(date_added)='{$today}'"));
    $resultData['users']['today'] = $loadData[0]['totalcount'];
    return $resultData;
}
 public function action_ajax_update($handler)
 {
     $users = Users::get();
     $payload = $handler->handler_vars->raw('payload');
     $decoded_payload = json_decode($payload);
     if (isset($decoded_payload)) {
         // Invalid decoded JSON is NULL.
         $commit_sha = $decoded_payload->after;
         $owner = isset($decoded_payload->repository->organization) ? $decoded_payload->repository->organization : $decoded_payload->repository->owner->name;
         $repo_URL = $decoded_payload->repository->url;
         $tree_URL = "https://api.github.com/repos/" . $owner . "/" . $decoded_payload->repository->name . "/git/trees/{$commit_sha}";
         $decoded_tree = json_decode(file_get_contents($tree_URL, 0, null, null));
         $xml_urls = array_map(function ($a) {
             if (strpos($a->path, ".plugin.xml") !== false || $a->path === 'theme.xml') {
                 return $a->url;
                 // path was just the filename, url is the API endpoint for the file itself
             }
         }, $decoded_tree->tree);
         $xml_urls = array_filter($xml_urls);
         // remove NULLs
         if (count($xml_urls) === 1) {
             $xml_URL = array_pop($xml_urls);
             $decoded_blob = json_decode(file_get_contents($xml_URL, 0, null, null));
             if ($decoded_blob->encoding === 'base64') {
                 $xml_data = base64_decode($decoded_blob->content);
             } else {
                 if ($decoded_blob->encoding === 'utf-8') {
                     // does it need to be decoded?
                 } else {
                     // there's an invalid encoding.
                     return;
                 }
             }
             $xml_object = simplexml_load_string($xml_data, 'SimpleXMLElement');
             /* can't hurt to hold onto these */
             $xml_object->addChild("xml_string", $xml_object->asXML());
             /* won't always need these */
             $xml_object->addChild("tree_url", $tree_URL);
             $xml_object->addChild("blob_url", $xml_URL);
             $xml_object->addChild("ping_contents", $payload);
             /* might need this. Or should it go in downloadurl? */
             $xml_object->addChild("repo_url", $repo_URL);
             /* need to check if there's already a posts with this guid */
             if (!isset($xml_object->guid) || trim($xml_object->guid) == '') {
                 // You must have a GUID or we can't find your plugin...
                 // @todo Send the owner an error message/file an issue on the repo
                 $this->file_issue($owner, $decoded_payload->repository->name, 'Info XML needs a GUID', "Habari addons require a GUID to be listed in the Addons Directory.<br>Please create and add a GUID to your xml file. You can use this one, which is new:<br><b>" . UUID::get() . "</b>");
             } else {
                 EventLog::log(_t('Making post for GUID %s', array(trim($xml_object->guid))), 'info');
                 self::make_post_from_XML($xml_object);
             }
         } else {
             // Wrong number of xml files.
             $this->file_issue($owner, $decoded_payload->repository->name, 'Too many XML files', "Habari addons should have a single XML file containing addon information.<br>");
         }
     } else {
         // Something has gone wrong with the json_decode. Do nothing, since there is nothing that can really be done.
     }
 }
Example #10
0
 public function get_delete($userID)
 {
     $user = Users::get($userID);
     if ($user != null) {
         return View::make('admin/users.delete')->with('user', $user);
     } else {
         return "Error";
     }
 }
Example #11
0
 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
 /**
  * Get the list of users this user follows.
  * @param  interger|null $id          user id
  * @param  array         $params      delimiting parameters
  * @param  array         $requestOpts request options
  * @return array         results
  */
 public function getFollows($id = null, $params = array(), $requestOpts = array())
 {
     if (null === $id) {
         if (null === $this->getAuthClientId()) {
             return parent::get('self/follows', $params, $requestOpts);
         }
         return parent::get($this->getAuthClientId() . '/follows', $params, $requestOpts);
     }
     return parent::get($id . '/follows', $params, $requestOpts);
 }
Example #13
0
 public function form()
 {
     $this->views = new Views(new Template("admin"));
     $this->views->title = "Adicionar voluntário";
     if (isset($this->get->uid)) {
         $this->views->title = "Editar voluntário";
         $this->views->data = Users::get($this->get->uid);
     }
     $this->views->display('users_form.phtml');
 }
Example #14
0
function loadApi($action)
{
    switch ($action) {
        case 'login':
            if (isset($_COOKIE['userid'])) {
                throw new Exception("You have been loggedin.");
            }
            $username = Request::get('username', '');
            $password = Request::get('password', '');
            try {
                Users::makeLogin($username, $password);
                return json_encode(array('error' => 'no', 'loggedin' => 'yes'));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'register':
            try {
                $id = Users::makeRegister();
                return json_encode(array('error' => 'no', 'userid' => $id));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'verify_email':
            $code = Request::get('verify_code', '');
            if ($code == '') {
                throw new Exception("Error Processing Request");
            }
            $loadData = Users::get(array('where' => "where verify_code='{$code}'"));
            if (isset($loadData[0]['userid'])) {
                Users::update($loadData[0]['userid'], array('verify_code' => ''));
                Redirect::to(ROOT_URL);
                // Users::sendNewPassword($loadData[0]['email']);
            } else {
                throw new Exception("Verify link not valid.");
            }
            break;
        case 'verify_forgotpassword':
            $code = Request::get('verify_code', '');
            if ($code == '') {
                throw new Exception("Error Processing Request");
            }
            $loadData = Users::get(array('where' => "where forgot_code='{$code}'"));
            if (isset($loadData[0]['userid'])) {
                Users::update($loadData[0]['userid'], array('forgot_code' => ''));
                Users::sendNewPassword($loadData[0]['email']);
                Redirect::to(ROOT_URL);
            } else {
                throw new Exception("Verify code not valid.");
            }
            break;
    }
}
Example #15
0
 public static function sendValidationEmail($uid)
 {
     $me = Users::get($uid);
     if (!$me) {
         return false;
     }
     $key = substr(md5(RANDOM_SALT . "_" . $me["email"]), 0, 5);
     $to = $me["email"];
     $subject = _("Email validation for the public OpenMediakit Transcoder");
     $message = sprintf(_("\nHi,\n\nSomeone, maybe you, created an account on a public OpenMediakit Transcoder service.\n\nThis email is sent to the subscription email to validate its ownership. Please click the link below if you want to confirm the account creation.\n\n%s\n\nPlease note that you will not be able to use this public transcoder until your email has been validated, since we may need to contact you if something goes wrong with this service.\n\nIf you didn't asked for this account, please ignore this message.\n\n--\nRegards,\n\nThe OpenMediakit Transcoder public instance service at\n%s\n"), FULL_URL . "users/validate/" . $me["uid"] . "/" . $key, FULL_URL);
     $headers = 'From: ' . MAIL_FROMNAME . ' <' . MAIL_FROM . '>' . "\r\n" . 'Reply-To: ' . MAIL_FROM . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
     mail($to, $subject, $message, $headers);
 }
Example #16
0
 /**
  * Performs an authentication
  * @param  array
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     if (count($credentials) == 1) {
         $row = $this->users->where('hash', $credentials[0])->fetch();
         if (!$row) {
             throw new NS\AuthenticationException("User not found.", self::IDENTITY_NOT_FOUND);
         }
     } else {
         list($username, $password) = $credentials;
         $row = $this->users->where('username', $username)->fetch();
         if (!$row) {
             throw new NS\AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
         }
         if ($row->password !== $this->users->calculateHash($password)) {
             throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
         }
         $this->users->get($row->id)->update(array('last_login' => new DibiDateTime(), 'last_ip' => $_SERVER['REMOTE_ADDR']));
     }
     $data = $row->toArray();
     unset($data['password']);
     return new NS\Identity($row->id, $row->role, $data);
 }
Example #17
0
 /**
  * Returns the current user's clients.
  *
  * @return \TableRecords\User[]
  */
 public function getClients()
 {
     $client_records = $this->by('coach_id', getUser()->id)->get();
     // Where the user is the coach..
     // Set user record for each client record.
     $users_table = new Users();
     foreach ($client_records as $i => $record) {
         $record->user = $users_table->get($record->client_id);
         if (!$record->user) {
             unset($client_records[$i]);
         }
     }
     $client_records = array_values($client_records);
     return $client_records;
 }
Example #18
0
 public function testThatFetchUserWithIdEqualOneFromDbWithCacheEnabled()
 {
     $userModel = new Users(array('db' => $this->db, 'cache' => $this->cache));
     $user_id = 1;
     $user = $userModel->get($user_id);
     $this->assertNotEmpty($user);
     foreach ($userModel->getCache()->getIds() as $cacheId) {
         // strpos will return boolean false if don't find Users__get
         // and user_id__i_$user_id substrings in $cacheId
         if (strpos($cacheId, 'Users__get') !== false && strpos($cacheId, "user_id__i_{$user_id}") !== false) {
             $this->assertEquals($user, $userModel->getCache()->load($cacheId));
             break;
         }
     }
 }
Example #19
0
 public function processuserAction()
 {
     $data = $this->getRequest()->getPost();
     $objectUser = new Users();
     if (!($this->view->status = $objectUser->save($data, true))) {
         $msg = Sydney_Messages::getInstance()->getMessages();
         $this->view->message = 'Validation errors found...';
         if (!is_array($msg)) {
             $this->view->message .= ' (' . $msg . ')';
         }
         $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => array());
     } else {
         // send email
         if (!$objectUser->isEditMode($data)) {
             $data['id'] = $objectUser->get()->id;
             $mailSubject = str_replace('[SITE_TITLE]', Sydney_Tools::getConf('general')->siteTitle, Sydney_Tools::_('subjectMailSubscribe'));
             $objectUser->registermail($objectUser->get()->login, $mailSubject, $data, $confirmationAction = '/publicms/profile/confirm/init/2', false, array('management/partialmailconfirm.phtml', 'publictimedex'));
         }
         $this->view->message = Sydney_Messages::getInstance()->getMessages();
         $this->view->ResultSet = array('errors' => Sydney_Messages::getInstance()->getMessages(), 'entry' => $objectUser->get()->toArray());
     }
     $this->view->showtime = 3;
     $this->view->modal = false;
 }
Example #20
0
 public function form()
 {
     Phalanx::loadClasses('Users');
     Phalanx::loadClasses('Godfather');
     $this->views = new Views(new Template("admin"));
     if (isset($this->get->cat_id)) {
         $this->views->data = Cats::get_details($this->get->cat_id);
         $this->views->title = "Gatos (Editando Registro)";
     } else {
         $this->views->title = "Gatos (Adicionar)";
     }
     $this->views->godfathers = Godfather::get_all(NULL, NULL, "nome ASC");
     $this->views->data->godfathers_list = unserialize($this->views->data->godfathers_list);
     $this->views->users = Users::get();
     $this->views->display('cats_form.phtml');
 }
Example #21
0
function insertProcess()
{
    $valid = Validator::make(array('send.firstname' => 'min:1|slashes', 'send.lastname' => 'min:1|slashes', 'send.groupid' => 'number|slashes', 'send.username' => 'min:3|slashes', 'send.email' => 'email|slashes', 'address.address_1' => 'slashes', 'address.address_2' => 'slashes', 'address.city' => 'slashes', 'address.state' => 'slashes', 'address.postcode' => 'slashes', 'address.country' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $username = Request::get('send.username');
    $email = Request::get('send.email');
    $loadData = Users::get(array('where' => "where username='******' OR email='{$email}'"));
    if (isset($loadData[0]['userid'])) {
        throw new Exception("This user have been exist in database.");
    }
    $send = Request::get('send');
    $address = Request::get('address');
    $thepass = Request::get('thepass');
    $passMd5 = String::encrypt($thepass);
    $send['password'] = $passMd5;
    $address['firstname'] = $send['firstname'];
    $address['lastname'] = $send['lastname'];
    $userid = Users::insert($send);
    $address['userid'] = $userid;
    Address::insert($address);
}
Example #22
0
File: links.php Project: rair/yacs
 /**
  * reference another page at this site
  *
  * The function transforms a local reference (e.g;, [code][user=2][/code])
  * to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]),
  * adds a title and, sometimes, set a description as well.
  *
  * @param string any string, maybe with a local reference in it
  * @return an array($url, $title, $description) or NULL
  *
  * @see images/view.php
  * @see links/edit.php
  * @see shared/codes.php
  */
 public static function transform_reference($text)
 {
     global $context;
     // translate this reference to an internal link
     if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) {
         switch ($matches[1]) {
             // article link
             case 'article':
                 if ($item = Articles::get($matches[2])) {
                     return array(Articles::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // section link
             // section link
             case 'section':
                 if ($item = Sections::get($matches[2])) {
                     return array(Sections::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // file link
             // file link
             case 'file':
                 if ($item = Files::get($matches[2])) {
                     return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name'])));
                 }
                 return array('', $text, '');
                 // image link
             // image link
             case 'image':
                 include_once $context['path_to_root'] . 'images/images.php';
                 if ($item = Images::get($matches[2])) {
                     return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
                 }
                 return array('', $text, '');
                 // category link
             // category link
             case 'category':
                 if ($item = Categories::get($matches[2])) {
                     return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
                 }
                 return array('', $text, '');
                 // user link
             // user link
             case 'user':
                 if ($item = Users::get($matches[2])) {
                     return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
                 }
                 return array('', $text, '');
         }
     }
     return array('', $text, '');
 }
Example #23
0
File: feed.php Project: rair/yacs
// check network credentials, if any -- used by winamp and other media players
if ($user = Users::authenticate()) {
    Surfer::empower($user['capability']);
}
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
} elseif (Surfer::is_logged()) {
    $id = Surfer::get_id();
}
$id = strip_tags($id);
// get the item from the database
$item = Users::get($id);
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// load the skin
load_skin('users');
// path to this page
$context['path_bar'] = array('users/' => i18n::s('People'));
// page title
function editMetaDataTable_Category($organisation_id = null, $group = null, $role = null, $proxy_id = null, MetaDataType $category)
{
    //for this case we have to get the users which are members of the relevant org, group, role, and where relevant? proxy_id
    $users = Users::get($organisation_id, $group, $role, $proxy_id);
    $types = MetaDataTypes::get($organisation_id, $group, $role, $proxy_id);
    $category_id = $category->getID();
    ob_start();
    foreach ($users as $user) {
        $values = getUserCategoryValues($user, $category);
        //var_dump($values);
        $descendant_type_sets = getDescendentTypesArray($types, $category);
        $label = html_encode($user->getFullname());
        ?>
	<tbody id="user_<?php 
        echo $user->getID();
        ?>
">
		<tr class="user_head" id="user_head_<?php 
        echo $user->getID();
        ?>
">
			<td></td>
			<th colspan="2"><?php 
        echo $label;
        ?>
</th>
			<td class="control" colspan="3"><ul class="page-action"><li class="last"><a href="#" class="add_btn" id="add_btn_<?php 
        echo $category_id;
        ?>
">Add record for <?php 
        echo $label;
        ?>
</a></li></ul></td>
		</tr>
		<?php 
        foreach ($values as $value) {
            echo editMetaDataRow($value, $category, $descendant_type_sets);
        }
        ?>
	</tbody>
	<?php 
    }
    $prepend = getHiddenMetaInputs($organisation_id, $group, $role, $category_id);
    return editMetaDataTable(ob_get_clean(), $prepend);
}
    /**
     * 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 #26
0
File: new.php Project: rair/yacs
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('E-mail has not been activated on this system.'));
    // no post account
} elseif ((!isset($context['mail_from']) || !$context['mail_from']) && (!isset($context['letter_reply_to']) || !$context['letter_reply_to'])) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(sprintf(i18n::s('No account to post the letter. Please %s.'), Skin::build_link('letters/configure.php', i18n::s('configure one'))));
    // prepare some announcement
} elseif (isset($action) && $action == 'announcement') {
    // the letter prefix
    if ($context['letter_prefix']) {
        $context['letter_body'] .= '<div>' . $context['letter_prefix'] . '</div>';
    }
    // body is free
    $context['letter_body'] .= "\n\n\n";
    // append surfer signature, if any
    if (Surfer::get_id() && ($user = Users::get(Surfer::get_id())) && $user['signature']) {
        $context['letter_body'] .= '<p>-----' . BR . strip_tags($user['signature'] . '</p>');
    }
    // the letter suffix
    if ($context['letter_suffix']) {
        $context['letter_body'] .= '<div>' . $context['letter_suffix'] . '</div>';
    }
    // the form to edit a letter
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>' . '<input type="hidden" name="action" value="send" />';
    // the letter title
    $label = i18n::s('Title');
    if (!isset($context['letter_title']) || !$context['letter_title']) {
        $context['letter_title'] = $context['site_name'];
    }
    $input = '<input type="text" name="letter_title" id="letter_title" size="50" value="' . encode_field(strip_tags($context['letter_title'])) . '" />';
    $hint = i18n::s('Used as message subject line');
Example #27
0
File: day.php Project: rair/yacs
 /**
  * get invitation default message
  *
  * This is put in the invitation form.
  *
  * @see articles/invite.php
  *
  * @param string 'PUBLISH' or 'CANCEL'
  * @return string to be put in the web form
  */
 function get_invite_default_message($method = 'PUBLISH')
 {
     global $context;
     // to be displayed into the web form for this invitation
     $text = '';
     if ($value = $this->anchor->get_title()) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR;
     }
     // dates
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR;
     }
     // build a link to the chairman page, if any
     if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR;
     }
     // event has been cancelled
     if ($method == 'CANCEL') {
         $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>';
     } else {
         // copy content of the introduction field, if any
         if ($value = $this->anchor->get_value('introduction')) {
             $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>';
         }
         // copy the induction message, if any
         if (isset($this->attributes['induction_message'])) {
             $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>';
         }
     }
     // done
     return $text;
 }
Example #28
0
 private function onEdit()
 {
     if ($this->_accessLevel < ACCESS_LEVEL_EDIT) {
         $this->listByView('Invalid user level for action.');
         return;
     }
     $companies = new Companies($this->_siteID);
     /* Bail out if we don't have a valid company ID. */
     if (!$this->isRequiredIDValid('companyID', $_POST)) {
         $this->listByView('Invalid company ID.');
         return;
     }
     /* Bail out if we don't have a valid owner user ID. */
     if (!$this->isOptionalIDValid('owner', $_POST)) {
         $this->listByView('Invalid owner user ID.');
         return;
     }
     /* Bail out if we don't have a valid billing contact ID. */
     if (!$this->isOptionalIDValid('billingContact', $_POST)) {
         $this->listByView('Invalid billing contact ID.');
         return;
     }
     $formattedPhone1 = StringUtility::extractPhoneNumber($this->getTrimmedInput('phone1', $_POST));
     if (!empty($formattedPhone1)) {
         $phone1 = $formattedPhone1;
     } else {
         $phone1 = $this->getTrimmedInput('phone1', $_POST);
     }
     $formattedPhone2 = StringUtility::extractPhoneNumber($this->getTrimmedInput('phone2', $_POST));
     if (!empty($formattedPhone2)) {
         $phone2 = $formattedPhone2;
     } else {
         $phone2 = $this->getTrimmedInput('phone2', $_POST);
     }
     $formattedFaxNumber = StringUtility::extractPhoneNumber($this->getTrimmedInput('faxNumber', $_POST));
     if (!empty($formattedFaxNumber)) {
         $faxNumber = $formattedFaxNumber;
     } else {
         $faxNumber = $this->getTrimmedInput('faxNumber', $_POST);
     }
     $url = $this->getTrimmedInput('url', $_POST);
     if (!empty($url)) {
         $formattedURL = StringUtility::extractURL($url);
         if (!empty($formattedURL)) {
             $url = $formattedURL;
         }
     }
     /* Hot company? */
     $isHot = $this->isChecked('isHot', $_POST);
     $companyID = $_POST['companyID'];
     $owner = $_POST['owner'];
     $billingContact = $_POST['billingContact'];
     /* Change ownership email? */
     if ($this->isChecked('ownershipChange', $_POST) && $owner > 0) {
         $companyDetails = $companies->get($companyID);
         $users = new Users($this->_siteID);
         $ownerDetails = $users->get($_POST['owner']);
         if (!empty($ownerDetails)) {
             $emailAddress = $ownerDetails['email'];
             /* Get the change status email template. */
             $emailTemplates = new EmailTemplates($this->_siteID);
             $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_OWNERSHIPASSIGNCLIENT');
             if (empty($statusChangeTemplateRS) || empty($statusChangeTemplateRS['textReplaced'])) {
                 $statusChangeTemplate = '';
             } else {
                 $statusChangeTemplate = $statusChangeTemplateRS['textReplaced'];
             }
             /* Replace e-mail template variables. */
             $stringsToFind = array('%CLNTOWNER%', '%CLNTNAME%', '%CLNTCATSURL%');
             $replacementStrings = array($ownerDetails['fullName'], $companyDetails['name'], '<a href="http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=companies&amp;a=show&amp;companyID=' . $companyID . '">' . 'http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?')) . '?m=companies&amp;a=show&amp;companyID=' . $companyID . '</a>');
             $statusChangeTemplate = str_replace($stringsToFind, $replacementStrings, $statusChangeTemplate);
             $email = $statusChangeTemplate;
         } else {
             $email = '';
             $emailAddress = '';
         }
     } else {
         $email = '';
         $emailAddress = '';
     }
     $name = $this->getTrimmedInput('name', $_POST);
     $address = $this->getTrimmedInput('address', $_POST);
     $city = $this->getTrimmedInput('city', $_POST);
     $state = $this->getTrimmedInput('state', $_POST);
     $zip = $this->getTrimmedInput('zip', $_POST);
     $keyTechnologies = $this->getTrimmedInput('keyTechnologies', $_POST);
     $notes = $this->getTrimmedInput('notes', $_POST);
     /* Departments list editor. */
     $departmentsCSV = $this->getTrimmedInput('departmentsCSV', $_POST);
     /* Bail out if any of the required fields are empty. */
     if (empty($name)) {
         $this->listByView('Required fields are missing.');
         return;
     }
     if (!eval(Hooks::get('CLIENTS_ON_EDIT_PRE'))) {
         return;
     }
     $departments = $companies->getDepartments($companyID);
     $departmentsDifferences = ListEditor::getDifferencesFromList($departments, 'name', 'departmentID', $departmentsCSV);
     $companies->updateDepartments($companyID, $departmentsDifferences);
     if (!$companies->update($companyID, $name, $address, $city, $state, $zip, $phone1, $phone2, $faxNumber, $url, $keyTechnologies, $isHot, $notes, $owner, $billingContact, $email, $emailAddress)) {
         CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to update company.');
     }
     if (!eval(Hooks::get('CLIENTS_ON_EDIT_POST'))) {
         return;
     }
     /* Update extra fields. */
     $companies->extraFields->setValuesOnEdit($companyID);
     /* Update contacts? */
     if (isset($_POST['updateContacts'])) {
         if ($_POST['updateContacts'] == 'yes') {
             $contacts = new Contacts($this->_siteID);
             $contacts->updateByCompany($companyID, $address, $city, $state, $zip);
         }
     }
     CATSUtility::transferRelativeURI('m=companies&a=show&companyID=' . $companyID);
 }
Example #29
0
 /** ********************************************************************
  * When a new client is searching for a public transcoder, it can call 
  * http://discovery.open-mediakit.org/public?application=<application>&version=<version>
  * to obtain a json-list of the currently active public transcoders.
  * then it choose one of them and call the subscribe api call
  * on this transcoder to subscribe to it and get an account there.
  * the parameters are : 
  * email: the email address of the subscriber (*it will be verified by sending an email*)
  * url: url of the api root of the client. will be used to call 
  * app_key: the api Key the client want me to use when contacting him, <=32 characters
  * application: client application that request an account
  * version: version of the client application
  * non-mandatory parameters:
  * lang: language of the client, default to en_US (for discussion & email verification text)
  * @return array the list of available settings on this transcoder. if the subscription was successfull.
  */
 public function app_subscribeAction()
 {
     if (!defined("PUBLIC_TRANSCODER") || !PUBLIC_TRANSCODER) {
         $this->api->apiError(API_ERROR_NOTPUBLIC, _("This server is not a public transcoder, please use another one"));
     }
     // anonymous api call   $this->me=$this->api->checkCallerIdentity();
     $this->api->enforceLimits();
     // for each params, tell its name, and its type and if it is mandatory
     $this->params = $this->api->filterParams(array("email" => array("string", true), "url" => array("string", true), "app_key" => array("string", true), "application" => array("string", true), "version" => array("string", true), "lang" => array("string", false, "en_US")));
     // TODO : use gettext to set the LOCALES according to the lang set by the caller.
     require_once MODULES . "/users/libs/users.php";
     $this->api->logApiCall("app_subscribe");
     // Check for application / version blacklist
     $this->api->allowApplication($this->params['application'], $this->params['version']);
     // Create an account
     $this->params['pass'] = Users::randomPass();
     $this->params['enabled'] = 1;
     $this->params['validated'] = 0;
     $this->params['admin'] = 0;
     $this->params['clientkey'] = $this->params['app_key'];
     unset($this->params['app_key']);
     $uid = Users::addUser($this->params);
     if (!$uid) {
         $this->api->apiError(API_ERROR_CREATEACCOUNT, _("An error happened when creating the account. Please retry later."));
     }
     $me = Users::get($uid);
     // Send a validation email to the user
     Users::sendValidationEmail($uid);
     $s = $this->api->getAllSettings();
     foreach ($s as $setting) {
         $settings[$setting["id"]] = array("id" => $setting["id"], "type" => $setting["type"], "slug" => $setting["slug"], "name" => $setting["name"], "technical" => $setting["technical"], "extension" => $setting["extension"], "recommend" => $setting["recommend"], "size_43" => $setting["size_43"], "size_169" => $setting["size_169"], "cardinality" => $setting["cardinality"]);
     }
     $this->api->returnValue(array("apikey" => $me["apikey"], "settings" => $settings));
 }
Example #30
0
 /**
  * the URL to start and to join the meeting
  *
  * @see overlays/events/start.php
  *
  * @return string the URL to redirect the user to the meeting, or NULL on error
  */
 function get_start_url()
 {
     global $context;
     // almost random passwords
     $this->initialize_passwords();
     // parameters to create a meeting
     $parameters = array();
     // use page id as meeting id
     $parameters[] = 'name=' . urlencode($this->attributes['id']);
     $parameters[] = 'meetingID=' . urlencode($this->attributes['id']);
     // surfer name, as authenticated by yacs
     $parameters[] = 'fullName=' . urlencode(Surfer::get_name());
     // moderator password
     $parameters[] = 'moderatorPW=' . urlencode($this->moderator_password);
     // participant password
     $parameters[] = 'attendeePW=' . urlencode($this->attendee_password);
     // ensure that the bridge number fits in the dialing plan
     $parameters[] = 'voiceBridge=' . urlencode(substr('7' . $this->attributes['id'] . '1234', 0, 5));
     // message displayed within the BigBlueButton session
     $welcome = '';
     // meeting title
     if (is_object($this->anchor)) {
         $welcome .= sprintf(i18n::s('%s: %s'), i18n::s('Title'), $this->anchor->get_title()) . "\n";
     }
     // meeting date
     if (isset($this->attributes['date_stamp'])) {
         $welcome .= sprintf(i18n::s('%s: %s'), i18n::s('Date'), Skin::build_date($this->attributes['date_stamp'], 'standalone')) . "\n";
     }
     // meeting duration
     if (isset($this->attributes['duration'])) {
         $welcome .= sprintf(i18n::s('%s: %s'), i18n::s('Duration'), $this->attributes['duration'] . ' ' . i18n::s('minutes')) . "\n";
     }
     // build a link to the owner page, if any
     if (is_object($this->anchor) && ($user = Users::get($this->anchor->get_value('owner_id')))) {
         $welcome .= sprintf(i18n::s('%s: %s'), i18n::s('Chairman'), $user['full_name']) . "\n";
     }
     // welcome message
     $parameters[] = 'welcome=' . urlencode($welcome);
     // return URL
     if (is_callable(array($this->anchor, 'get_url'))) {
         $parameters[] = 'logoutURL=' . urlencode($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url());
     }
     // should we record this session?
     if ($this->with_session_recording()) {
         $parameters[] = 'record=true';
         $parameters[] = 'duration=125';
         // 2 hours max per recording
     }
     // link to create the meeting
     $url = $this->build_link('create', $parameters);
     // list most recent files that have been attached to this page
     $headers = NULL;
     $body = NULL;
     if (is_object($this->anchor) && ($files = Files::list_by_date_for_anchor($this->anchor->get_reference(), 0, 5, 'raw'))) {
         $headers = array("Content-Type: text/xml");
         // instruct the presentation module to pre-load these files
         $body = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<modules>' . "\n" . '	<module name="presentation">' . "\n";
         // list web address of each file
         foreach ($files as $file) {
             $body .= "\t\t" . '<document' . ' url="' . $context['url_to_home'] . $context['url_to_root'] . utf8::to_xml(Files::get_url($file['id'], 'fetch', $file['file_name'])) . '"' . ' name="' . utf8::to_xml($file['file_name']) . '"' . ' />' . "\n";
         }
         // end of the list of files
         $body .= '   </module>' . "\n" . '</modules>' . "\n";
     }
     // do create the meeting
     if (($response = http::proceed_natively($url, $headers, $body)) && ($xml = simplexml_load_string($response)) && $xml->returncode == 'SUCCESS') {
         // parameters to join the meeting
         $parameters = array();
         // use page id as meeting id
         $parameters[] = 'meetingID=' . urlencode($xml->meetingID);
         // surfer name, as authenticated by yacs
         $parameters[] = 'fullName=' . urlencode(Surfer::get_name());
         // moderator password
         $parameters[] = 'password='******'join', $parameters);
         return $url;
     }
     // problem, darling!
     return NULL;
 }