function messages_pagesetup() { // register links -- global $profile_id, $PAGE, $CFG, $metatags, $function, $USER; $pgowner = $profile_id; require_once $CFG->dirroot . "mod/messages/lib/messages_config.php"; require_once $CFG->dirroot . "mod/messages/default_template.php"; if (isloggedin() && user_info("user_type", $_SESSION['userid']) != "external") { // Add the JavaScript functions // Lose the trailing slash $url = substr($CFG->wwwroot, 0, -1); $metatags .= "<script language=\"javascript\" type=\"text/javascript\" src=\"{$url}/mod/messages/messages.js\"></script>"; $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/messages/css.css\" type=\"text/css\" media=\"screen\" />"; $messages = count_records_select('messages', 'to_id=' . $USER->ident . " AND status='unread'"); if (defined("context") && context == "messages" && $pgowner == $_SESSION['userid']) { $PAGE->menu[] = array('name' => 'messages', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/" class="selected">' . __gettext("Messages") . " ({$messages})" . '</a></li>'); } else { $PAGE->menu[] = array('name' => 'messages', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/">' . __gettext("Messages") . " ({$messages})" . '</a></li>'); } if (profile_permissions_check("profile") && defined("context") && context == "messages") { if (user_type($pgowner) == "person") { $PAGE->menu_sub[] = array('name' => 'messages:list', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/">' . __gettext("View Messages") . '</a>'); $PAGE->menu_sub[] = array('name' => 'messages:compose', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/compose">' . __gettext("Compose") . '</a>'); $PAGE->menu_sub[] = array('name' => 'messages:sent', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/messages/sent">' . __gettext("Sent Messages") . '</a>'); } } } }
function friend_pagesetup() { // register links -- global $profile_id; global $PAGE; global $CFG; global $metatags; require_once dirname(__FILE__) . "/default_template.php"; require_once dirname(__FILE__) . "/lib/friends_config.php"; $metatags .= "<link rel=\"stylesheet\" href=\"" . $CFG->wwwroot . "mod/friend/css.css\" type=\"text/css\" media=\"screen\" />"; $page_owner = $profile_id; if (isloggedin()) { if (defined("context") && context == "network" && $page_owner == $_SESSION['userid']) { $PAGE->menu[] = array('name' => 'friends', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/friends/\" class=\"selected\" >" . __gettext("Contacts") . '</a></li>'); } else { $PAGE->menu[] = array('name' => 'friends', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/friends/\" >" . __gettext("Contacts") . '</a></li>'); } } if (defined("context") && context == "network") { if (user_type($page_owner) == "person" || user_type($page_owner) == "external") { $friends_username = user_info('username', $page_owner); $PAGE->menu_sub[] = array('name' => 'friend', 'html' => a_href("{$CFG->wwwroot}{$friends_username}/friends/", __gettext("My friends"))); /*$PAGE->menu_sub[] = array( 'name' => 'friend:of', 'html' => a_href( "{$CFG->wwwroot}{$friends_username}/friendsof/", __gettext("Friend of")));*/ if (isloggedin() && $page_owner == $_SESSION['userid']) { $PAGE->menu_sub[] = array('name' => 'friend:requests', 'html' => a_href("{$CFG->wwwroot}{$friends_username}/friends/requests", __gettext("Friendship requests"))); } if (FRIENDS_FOAF) { $PAGE->menu_sub[] = array('name' => 'friend:foaf', 'html' => a_href("{$CFG->wwwroot}{$friends_username}/foaf/", __gettext("FOAF"))); } } } }
function profile_pagesetup() { // register links -- global $profile_id; global $PAGE; global $CFG; // don't clobber $page_owner, use a // local $pgowner instead for clarity $pgowner = $profile_id; if (isloggedin()) { if (defined("context") && context == "profile" && $pgowner == $_SESSION['userid']) { $PAGE->menu[] = array('name' => 'profile', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/" class="selected">' . __gettext("Profile") . '</a></li>'); } else { $PAGE->menu[] = array('name' => 'profile', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/">' . __gettext("Profile") . '</a></li>'); } if (profile_permissions_check("profile") && defined("context") && context == "profile") { if (user_type($pgowner) == "person") { $PAGE->menu_sub[] = array('name' => 'profile:edit', 'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $pgowner . '">' . __gettext("Edit this profile") . '</a>'); $PAGE->menu_sub[] = array('name' => 'profile:picedit', 'html' => '<a href="' . $CFG->wwwroot . '_icons/?context=profile&profile_id=' . $pgowner . '">' . __gettext("Change site picture") . '</a>'); if (!empty($CFG->uses_YUI)) { $PAGE->menu_sub[] = array('name' => 'profile:widget:manage', 'html' => '<a href="' . $CFG->wwwroot . 'mod/widget/manage_widgets.php">' . __gettext("Manage widgets") . '</a>'); } /*else { $PAGE->menu_sub[] = array ( 'name' => 'profile:widget:add', 'html' => '<a href="' . $CFG->wwwroot . 'mod/profile/add.php?owner=' . $pgowner . '">' . __gettext("Add widget") . '</a>'); }*/ } } } $PAGE->search_menu[] = array('name' => __gettext("People"), 'user_type' => 'person'); }
/** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(MessageUserRequest $request) { try { $mails = $request->get('mails'); $attributes = $request->all(); $attributes['user_id'] = user_id('web'); $attributes['user_type'] = user_type(); $attributes['name'] = user()->name; $attributes['from'] = user()->email; $attributes['to'] = implode(",", $mails); $attributes['status'] = $request->get('status'); $message = $this->repository->create($attributes); if ($request->get('status') == 'Sent') { foreach ($mails as $mail) { $attributes['status'] = "Inbox"; $message1 = $this->repository->create($attributes); } } $sent_count = $this->repository->msgCount('Sent'); $inbox_count = $this->repository->msgCount('Inbox'); return response()->json(['message' => trans('messages.success.updated', ['Module' => trans('message::message.name')]), 'code' => 204, 'redirect' => trans_url('/user/message/message/' . $message->getRouteKey()), 'sent_count' => $sent_count, 'inbox_count' => $inbox_count], 201); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 400], 400); } }
function community_pagesetup() { // register links -- global $profile_id; global $PAGE; global $CFG; global $USER; require_once dirname(__FILE__) . "/default_template.php"; require_once dirname(__FILE__) . "/lib/communities_config.php"; $page_owner = $profile_id; $usertype = user_type($page_owner); $username = user_info('username', $page_owner); if (isloggedin()) { if (COMMUNITY_CONTEXT != "network") { if (defined("context") && context == COMMUNITY_CONTEXT) { $PAGE->menu[] = array('name' => 'community', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" class=\"selected\" >" . __gettext("Communities") . '</a></li>'); } else { $PAGE->menu[] = array('name' => 'community', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/communities\" >" . __gettext("Communities") . '</a></li>'); } } } if ($usertype == "community") { /*$PAGE->menu_sub[] = array( 'name' => 'profile:edit', 'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$page_owner.'">' . __gettext("Edit community profile") . '</a>');*/ $PAGE->menu_sub[] = array('name' => 'community:pic', 'html' => a_href("{$CFG->wwwroot}_icons/?context=profile&profile_id={$page_owner}", __gettext("Community site picture"))); $PAGE->menu_sub[] = array('name' => 'community:edit', 'html' => a_href("{$CFG->wwwroot}_userdetails/?context=profile&profile_id={$page_owner}", __gettext("Edit community details"))); /*$PAGE->menu_sub[] = array( 'name' => 'profile:view', 'html' => a_href("{$CFG->wwwroot}{$username}/profile", __gettext("Return to community profile")));*/ $PAGE->menu_sub[] = array('name' => 'community:adminmembers', 'html' => a_href("{$CFG->wwwroot}{$username}/community/members", __gettext("Edit members"))); $PAGE->menu_sub[] = array('name' => 'community:requests', 'html' => a_href("{$CFG->wwwroot}{$username}/community/requests", __gettext("View membership requests"))); $PAGE->menu_sub[] = array('name' => 'community:invite', 'html' => a_href("{$CFG->wwwroot}{$username}/community/invite", __gettext("Invite people"))); $PAGE->menu_sub[] = array('name' => 'community:invite', 'html' => a_href("{$CFG->wwwroot}{$USER->username}/communities", __gettext("Back to communities"))); } else { if ($usertype == "person") { if (defined("context") && context == COMMUNITY_CONTEXT) { if (COMMUNITY_COMPACT_VIEW) { $PAGE->menu_sub[] = array('name' => 'community', 'html' => a_href("{$CFG->wwwroot}{$username}/communities", __gettext("My Communities"))); if (logged_on && $page_owner == $_SESSION['userid'] && ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident))) { $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/new", __gettext("New Community"))); } } else { if ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident)) { $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/create", __gettext("Create a Community"))); $PAGE->menu_sub[] = array('name' => 'community', 'html' => a_href("{$CFG->wwwroot}{$username}/communities", __gettext("My Communities"))); if ($CFG->community_create_flag == "" || user_flag_get($CFG->community_create_flag, $USER->ident)) { $PAGE->menu_sub[] = array('name' => 'community:owned', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/owned", __gettext("Owned Communities"))); } } } } } } $PAGE->search_menu[] = array('name' => __gettext("Communities"), 'user_type' => 'community'); // Add membership requests to the personal network page if (defined("context") && context == "community" && isloggedin() && $page_owner == $_SESSION['userid']) { $PAGE->menu_sub[] = array('name' => 'membership:invites', 'html' => a_href("{$CFG->wwwroot}{$username}/communities/invitations", __gettext("Community invitations"))); } }
/** * Returns the HTML to display a user's icon, with event hooks allowing for interception. * Internally passes around a "user_icon" "display" event, with an object * containing the elements 'html', 'icon' (being the icon ID), 'size', 'owner' and 'url'. * * @uses $CFG * @param integer $icon_id The unique ID of the user we want to display the icon for. * @param integer $size The size of the icon we want to display (max: 100). * @param boolean $urlonly If true, returns the URL of the icon rather than the full HTML. * @return string Returns the icon HTML, or the default icon if something went wrong (eg the user didn't exist). */ function icon_html($icon_id, $size = 100, $urlonly = false) { global $CFG; global $profile_id; $extra = ""; $user_icon = new stdClass(); $user_icon->size = $size; if ($size < 100) { $extra = "/h/{$size}/w/{$size}"; } $profile_icon = user_info("icon", $profile_id); $user_type = user_type($profile_id); $user_icon->icon = $icon_id; if ($user_icon->icon != -1 && $user_icon->icon != $profile_icon) { $user_icon->url = "{$CFG->wwwroot}_icon/user/{$user_icon->icon}{$extra}"; $user_icon->html = "<img src=\"{$user_icon->url}\" border=\"0\" alt=\"user icon\" />"; if ($urlonly) { return $user_icon->url; } else { return $user_icon->html; } } if ($urlonly) { return -1; } else { $extensionContext = trim(optional_param('extension', 'weblog')); if (array_key_exists($extensionContext, $CFG->weblog_extensions) && array_key_exists('icon', $CFG->weblog_extensions[$extensionContext])) { $icon = $CFG->weblog_extensions[$extensionContext]['icon']; return "<img src=\"{$icon}\" border=\"0\" alt=\"default user icon\" width=\"{$size}\" heigh=\"{$size}\"/>"; } else { return "<img src=\"{$CFG->wwwroot}_icon/user/{$profile_icon}{$extra}\" border=\"0\" alt=\"default user icon\" />"; } } }
public function classSectionManagement() { if (user_type() == 3 || user_type() == 5) { $this->loadPage("section/class_section_management", "section/class_section_management_script", false); } else { header("Location: " . base_url()); } }
public function gradingsystem() { if (user_type() == 6) { $this->loadPage("subject/grading_system", "subject/grading_system_script", false); } else { header("Location: " . base_url()); } }
public function roomManagement() { if (user_type() == 3) { $this->loadPage("room/room_management", "room/room_management_script", false); } else { header("Location: " . base_url()); } }
public function assessmentItemReport() { if (user_type() == 5 || user_type() == 3) { $this->loadPage("report/finance/assessment_item_report", "report/finance/assessment_item_report_script", false); } else { header("Location: " . base_url()); } }
public function accountStatement() { if (user_type() == 5) { $this->loadPage("teller/account_statement", "teller/account_statement_script", false); } else { header("Location: " . base_url()); } }
public function accountAdjustmentFee() { if (user_type() == 3 || user_type() == 6 || user_type() == 5) { $this->loadPage("registrar/account_adjustment_fee", "registrar/account_adjustment_fee_script", false); } else { header("Location: " . base_url()); } }
public function facultyManagement() { if (user_type() == 3) { $this->loadPage("employee/faculty_management", "employee/faculty_management_script", false); } else { header("Location: " . base_url()); } }
public function clubManagement() { if (user_type() == 3 || user_type() == 5) { $this->loadPage("club/club_management", "club/club_management_script", false); } else { header("Location: " . base_url()); } }
public function studentYearlyDeductible() { if (user_type() == 3 || user_type() == 5) { $this->loadPage("finance/student_yearly_deductible", "finance/student_yearly_deductible_script", false); } else { header("Location: " . base_url()); } }
function index() { $script = array("waste_map_script"); if (user_type() * 1 === 3) { $script[] = "waste_map_lgu_script"; } else { $script[] = "waste_map_normal_user_script"; } $this->loadPage("waste_map", $script, array()); }
/** * Weblog class constructor * * <p>Will set all weblog properties, if the provided weblog id exist * (which effectively will be a user id, regardless if one is dealing * with a person or a community - for Elgg both are users).</p> * * @param int $user_id The user id. * @param int $blog_id The weblog id. */ function Weblog($user_id, $blog_id) { $this->community = false; // dealing with community or not // username/id conversions if (is_numeric($user_id)) { $this->user_id = $user_id; } elseif (is_string($user_id)) { $this->user_id = user_info_username('ident', $user_id); } if (is_numeric($blog_id)) { $this->ident = $blog_id; } elseif (is_string($blog_id)) { $this->ident = user_info_username('ident', $blog_id); } // Are we dealing with a person or a community? if (user_type($this->ident) == "person") { if ($result = get_record('users', 'ident', $this->user_id)) { $this->user_name = $result->name; $this->user_username = $result->username; } $posts = get_records_select('weblog_posts', "owner = ? AND weblog = ?", array($this->user_id, $this->user_id), 'posted DESC'); $this->blog_name = $this->user_name; $this->blog_username = $this->user_username; $this->owner = $this->user_id; } else { // It's a community $this->community = true; // Get the owner $this->owner = user_info('owner', $this->ident); // Inject an SQL restriction if the user is not owner $sql_insert = ""; if ($this->owner != $this->user_id) { $sql_insert = " and owner = {$this->user_id} "; } if ($result = get_record('users', 'ident', $this->ident)) { $this->blog_name = $result->name; $this->blog_username = $result->username; } $posts = get_records_select('weblog_posts', "weblog = {$this->ident} {$sql_insert}", null, 'posted DESC'); $user = run('users:instance', array('user_id' => $this->user_id)); $this->user_name = $user->getName(); $this->user_username = $user->getUserName(); } $this->posts = array(); if (is_array($posts) && sizeof($posts) > 0) { foreach ($posts as $post) { $this->posts[] = $post->ident; } } else { } }
/** * Create new portfolio. * * @param Request $request * * @return json */ public function store(PortfolioAdminApiRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.api'); $attributes['user_type'] = user_type(); $portfolio = $this->repository->create($attributes); $portfolio = $portfolio->presenter(); $portfolio['code'] = 2004; return response()->json($portfolio)->setStatusCode(201, 'STORE_SUCCESS'); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 4004])->setStatusCode(400, 'STORE_ERROR'); } }
public function createAccount() { $this->accessNumber = 1; //registration $valid = true; if (!$valid) { $this->responseError(5, "Captcha Required"); } if ($this->checkACL() && ($this->input->post("account_type_ID") == 1 && user_type() == 1 || $this->input->post("account_type_ID") == 3 && user_type() == 1 || $this->input->post("account_type_ID") == 2 && $this->input->post("status") == 3 && $this->validReCaptcha())) { $this->form_validation->set_rules('username', 'Username', 'required|is_unique[account.username]'); $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]'); $this->form_validation->set_rules('account_type_ID', 'Account Type', 'required'); $this->form_validation->set_rules('first_name', 'First Name', 'required'); $this->form_validation->set_rules('middle_name', 'Middle Name', 'required'); $this->form_validation->set_rules('last_name', 'Last Name', 'required'); $this->form_validation->set_rules('email_address', 'Email Address', 'required|valid_email|is_unique[account_contact_information.detail]'); if ($this->form_validation->run()) { $result = $this->m_account->createAccount($this->input->post("username"), $this->input->post("password"), $this->input->post("account_type_ID"), $this->input->post("status")); if ($result) { $this->load->model("m_account_basic_information"); $this->m_account_basic_information->createAccountBasicInformation($result, $this->input->post("first_name"), $this->input->post("middle_name"), $this->input->post("last_name")); $this->load->model("M_account_contact_information"); $this->M_account_contact_information->createAccountContactInformation($result, 1, $this->input->post("email_address")); //Send Email Confirmation if ($this->input->post("account_type_ID") == 2) { $this->load->library('email'); $this->email->from('*****@*****.**', 'John Enrick'); $this->email->to($this->input->post("email_address")); $this->email->subject('Wasteline Registration Verification'); $this->email->message("Good day " . $this->input->post('username') . "! Thank you for registering in Wasteline.\nTo verify you accout, please click the following link: " . base_url("porta/accountVerification/" . ("" + $result . ("" + time())))); $this->email->send(); } $this->actionLog($result); $this->responseData($result); } else { $this->responseError(3, "Failed to create"); } } else { if (count($this->form_validation->error_array())) { $this->responseError(102, $this->form_validation->error_array()); } else { $this->responseError(100, "Required Fields are empty"); } } } else { $this->responseError(1, "Not Authorized"); } $this->outputResponse(); }
public function deleteGeneralLedger() { $response = $this->generateResponse(); if (!$this->checkACL(user_type(), API_Controller::STUDENT_MANAGEMENT)) { // if not admin $response["error"][] = array("status" => 1, "message" => "Not Authorized"); } else { $result = $this->m_general_ledger->deleteGeneralLedger($this->input->post("ID")); if ($result) { $response["data"] = $result; } else { $response["error"][] = array("status" => 1, "message" => "Failed to delete"); } } echo json_encode($response); }
public function deleteAssessmentType() { $response = $this->generateResponse(); if (user_type() != 3) { // if not admin $response["error"][] = array("status" => 1, "message" => "Not Authorized"); } else { $result = $this->m_assessment_type->deleteAssessmentType($this->input->post("ID")); if ($result) { $this->m_change_log->createChangeLog(4, user_id(), json_encode(array("message" => "Delete Assessment Type", "associated_ID" => $this->input->post("ID")))); $response["data"] = $result; } else { $response["error"][] = array("status" => 1, "message" => "Failed to delete"); } } echo json_encode($response); }
public function updateSaleOrder() { $this->accessNumber = 4; if ($this->checkACL() && ($this->input->post("status") === 0 || $this->input->post("status") === 1 || $this->input->post("status") === 2 && user_type() == 2)) { $this->responseDebug($this->input->post()); $result = $this->m_sale_order->updateSaleOrder($this->input->post("ID"), $this->input->post("condition_customer_company_representative_account_ID"), $this->input->post("condition_remarks"), $this->input->post("condition_datetime"), $this->input->post("customer_company_representative_account_ID"), $this->input->post("remarks"), $this->input->post("datetime"), $this->input->post("status")); if ($result) { $this->actionLog($result); $this->responseData($result); } else { $this->responseError(3, "Failed to Update"); } } else { $this->responseError(1, "Not Authorized"); } $this->outputResponse(); }
public function retrieveAccessControlList() { $condition = array(); $condition["group_ID"] = user_type() * 1; $condition["account_ID"] = user_id() * 1; $this->responseDebug($condition); $ACL = $this->m_access_control_list->retrieveAccessControlList(false, false, false, NULL, NULL, $condition); $groupACL = $this->m_access_control_list->retrieveGroupAccessControlList(false, false, false, NULL, NULL, $condition); $data = array(); if ($ACL || $groupACL) { $data["access_control_list"] = $ACL; $data["group_access_control_list"] = $groupACL; } else { $this->responseError(1, "No Result"); } $this->responseData($data); $this->outputResponse(); }
public function updateReport() { $this->accessNumber = 4; $condition = $this->input->post("condition") ? $this->input->post("condition") : array(); if (user_type() != 3) { $condition["reporter_account_ID"] = user_id(); } if ($this->checkACL()) { $result = $this->m_report->updateReport($this->input->post("ID"), $condition, $this->input->post("updated_data")); if ($result) { $this->actionLog(json_encode($this->input->post())); $this->responseData($result); } else { $this->responseError(3, "Failed to Update"); } } else { $this->responseError(1, "Not Authorized"); } $this->outputResponse(); }
public function deleteAssessmentItem() { $response = $this->generateResponse(); if (user_type() != 3 && user_type() != 5) { // if not admin $response["error"][] = array("status" => 1, "message" => "Not Authorized"); } else { if (!$this->m_assessment_item->assessmentItemExistInUsed($this->input->post("ID"))) { $result = $this->m_assessment_item->deleteAssessmentItem($this->input->post("ID")); if ($result) { $response["data"] = $result; } else { $response["error"][] = array("status" => 1, "message" => "Failed to delete"); } } else { $response["error"][] = array("status" => 2, "message" => "Item is in use."); } } echo json_encode($response); }
public function logInAccount() { $response = $this->generateResponse(); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Account Username', 'required'); $this->form_validation->set_rules('password', 'Account Password', 'required'); if ($this->form_validation->run()) { $result = $this->m_account->retrieveAccount(false, false, 0, false, $this->input->post("username"), $this->input->post("password")); if ($result) { $accountInformation = $this->m_account->retrieveAccountBasicInformation(false, false, false, false, $result["ID"]); $this->session->set_userdata("user_type", $result["account_type_ID"]); $this->session->set_userdata("user_ID", $result["ID"]); $this->session->set_userdata("first_name", $accountInformation["first_name"]); $this->session->set_userdata("last_name", $accountInformation["last_name"]); $this->session->set_userdata("middle_name", $accountInformation["middle_name"]); if (user_type() == 3) { $response["data"] = base_url() . "registrar/c_registrar/studentAccountManagement"; } else { if (user_type() == 5) { $response["data"] = base_url() . "teller/c_teller/tellerTransaction"; } else { if (user_type() == 6) { $response["data"] = base_url() . "subject/c_subject/classList"; } else { $response["data"] = base_url(); } } } } else { $response["error"][] = array("status" => 2, "message" => "Username and Password doesn't match!"); } } else { $response["error"][] = array("status" => 1, "message" => validation_errors()); } echo json_encode($response); }
/** * Create new forum. * * @param Request $request * * @return Response */ public function store(ForumAdminRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $attributes['user_type'] = user_type(); $forum = $this->repository->create($attributes); return response()->json(['message' => trans('messages.success.updated', ['Module' => trans('forum::forum.name')]), 'code' => 204, 'redirect' => trans_url('/admin/forum/forum/' . $forum->getRouteKey())], 201); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'code' => 400], 400); } }
/** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(ResumeUserRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $resume = $this->repository->create($attributes); return redirect(trans_url('/user/career/resume'))->with('message', trans('messages.success.created', ['Module' => trans('career::resume.name')]))->with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } }
function twitter_process($url, $post_data = false) { if ($post_data === true) { $post_data = array(); } if (user_type() == 'oauth' && (strpos($url, '/twitter.com') !== false || strpos($url, 'api.twitter.com') !== false)) { user_oauth_sign($url, $post_data); } elseif (strpos($url, 'api.twitter.com') !== false && is_array($post_data)) { // Passing $post_data as an array to twitter.com (non-oauth) causes an error :( $s = array(); foreach ($post_data as $name => $value) { $s[] = $name . '=' . urlencode($value); } $post_data = implode('&', $s); } $api_start = microtime(1); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); if ($post_data !== false && !$_GET['page']) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } if (user_type() != 'oauth' && user_is_authenticated()) { curl_setopt($ch, CURLOPT_USERPWD, user_current_username() . ':' . $GLOBALS['user']['password']); } //from http://github.com/abraham/twitteroauth/blob/master/twitteroauth/twitteroauth.php curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HEADER, FALSE); $response = curl_exec($ch); $response_info = curl_getinfo($ch); $erno = curl_errno($ch); $er = curl_error($ch); curl_close($ch); global $api_time; $api_time += microtime(1) - $api_start; switch (intval($response_info['http_code'])) { case 200: case 201: $json = json_decode($response); if ($json) { return $json; } return $response; case 401: user_logout(); theme('error', "<p>Error: Login credentials incorrect.</p><p>{$response_info['http_code']}: {$result}</p><hr><p>{$url}</p>"); case 0: $result = $erno . ":" . $er . "<br />"; /* foreach ($response_info as $key => $value) { $result .= "Key: $key; Value: $value<br />"; } */ theme('error', '<h2>Twitter timed out</h2><p>Dabr gave up on waiting for Twitter to respond. They\'re probably overloaded right now, try again in a minute. <br />' . $result . ' </p>'); default: $result = json_decode($response); $result = $result->error ? $result->error : $response; if (strlen($result) > 500) { $result = 'Something broke on Twitter\'s end.'; /* $result .= $erno . ":" . $er . "<br />" ; foreach ($response_info as $key => $value) { $result .= "Key: $key; Value: $value<br />"; } */ } theme('error', "<h2>An error occured while calling the Twitter API</h2><p>{$response_info['http_code']}: {$result}</p><hr><p>{$url}</p>"); } }
); $run_result .= "</li>";*/ } else { $posts = count_records_select('weblog_posts', '(' . run("users:access_level_sql_where", $profile_id) . ") and owner = {$profile_id}"); if (logged_on || isset($page_owner) && $page_owner != -1) { $title = __gettext("Blog"); $weblog_username = user_info('username', $profile_id); $body = <<<END END; if (user_type($page_owner) == "person") { $personalWeblog = __gettext("Personal blog"); $body .= <<<END <a href="{$CFG->wwwroot}{$weblog_username}/weblog/">{$personalWeblog}</a> <a href="{$CFG->wwwroot}{$weblog_username}/weblog/rss"><img src="{$CFG->wwwroot}mod/template/icons/rss.png" alt="RSS" border="0" /><br></a> END; } else { if (user_type($page_owner) == "community") { $communityWeblog = __gettext("Community blog"); $body .= <<<END <a href="{$CFG->wwwroot}{$weblog_username}/weblog/">{$communityWeblog}</a> <a href="{$CFG->wwwroot}{$weblog_username}/weblog/rss"><img src="{$CFG->wwwroot}mod/template/icons/rss.png" alt="RSS" border="0" /><br></a> END; } } $blogArchive = __gettext("Weblog Archive"); $friendWeblog = __gettext("Friends blog"); $body .= <<<END <a href="{$CFG->wwwroot}{$weblog_username}/weblog/archive/">{$blogArchive}<br></a><br> <!--a href="{$CFG->wwwroot}{$weblog_username}/weblog/friends/">{$friendWeblog}<br><br></a--> END; //$run_result .= "<li id=\"sidebar_weblog\">"; $run_result .= templates_draw(array('context' => 'sidebarholder', 'title' => $title, 'body' => $body)); //$run_result .= "</ul></li>";