当前位置: 首页>>代码示例>>PHP>>正文


PHP admin::permissions方法代码示例

本文整理汇总了PHP中admin::permissions方法的典型用法代码示例。如果您正苦于以下问题:PHP admin::permissions方法的具体用法?PHP admin::permissions怎么用?PHP admin::permissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在admin的用法示例。


在下文中一共展示了admin::permissions方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     $this->template->this_page = 'settings';
     if (!admin::permissions($this->user, "manage")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
 }
开发者ID:huslage,项目名称:Ushahidi_Web,代码行数:8,代码来源:api.php

示例2: __construct

 function __construct()
 {
     parent::__construct();
     $this->template->this_page = 'messages';
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "messages_reporters")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
 }
开发者ID:mewsop,项目名称:Ushahidi_Web,代码行数:9,代码来源:reporters.php

示例3: __construct

 function __construct()
 {
     parent::__construct();
     $this->template->this_page = Kohana::lang('ui_admin.settings');
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "settings")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
 }
开发者ID:kjgarza,项目名称:thrasos,代码行数:9,代码来源:themes.php

示例4: __construct

 function __construct()
 {
     parent::__construct();
     $this->template->this_page = 'settings';
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "settings")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     $this->cache = Cache::instance();
 }
开发者ID:kvin33,项目名称:Ushahidi_Web,代码行数:10,代码来源:settings.php

示例5: __construct

 function __construct()
 {
     parent::__construct();
     $this->template->this_page = 'users';
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "users")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     $this->display_roles = admin::permissions($this->user, 'manage_roles');
 }
开发者ID:mewsop,项目名称:Ushahidi_Web,代码行数:10,代码来源:users.php

示例6: __construct

 function __construct()
 {
     parent::__construct();
     $this->template->this_page = 'settings';
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "manage")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     $this->_registered_blocks = Kohana::config("settings.blocks");
 }
开发者ID:kjgarza,项目名称:ushahidi,代码行数:10,代码来源:blocks.php

示例7: index

 /**
  * Export the reports to a CSV file
  * @param int $page
  */
 function index()
 {
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "reports_download")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     //export that data
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         //get that table prefix
         $table_prefix = Kohana::config('database.default.table_prefix');
         //get the IVR data from the database
         $sql = "SELECT incident_id, ivr_code, incident.incident_title as well_title, location.location_name as well_location, phone_number, well_working, time_received ";
         $sql .= "FROM " . $table_prefix . "ivrapi_data ";
         $sql .= "LEFT JOIN " . $table_prefix . "incident AS incident ON incident.id = ivrapi_data.incident_id ";
         $sql .= "LEFT JOIN " . $table_prefix . "location AS location ON incident.location_id = location.id ";
         $db = new Database();
         $ivr_data = $db->query($sql);
         $ivr_csv = $this->_csv_text(Kohana::lang('ivr_api.ivr_code'));
         $ivr_csv .= ',' . $this->_csv_text(Kohana::lang('ivr_api.well_title'));
         $ivr_csv .= ',' . $this->_csv_text(Kohana::lang('ivr_api.well_location'));
         $ivr_csv .= ',' . $this->_csv_text(Kohana::lang('ivr_api.phone_number'));
         $ivr_csv .= ',' . $this->_csv_text(Kohana::lang('ivr_api.well_working'));
         $ivr_csv .= ',' . $this->_csv_text(Kohana::lang('ivr_api.time_received'));
         $ivr_csv .= "\n";
         //now loop through the data
         foreach ($ivr_data as $data) {
             $ivr_csv .= '"="' . $this->_csv_text($data->ivr_code) . '""';
             $ivr_csv .= ',' . $this->_csv_text($data->well_title);
             $ivr_csv .= ',' . $this->_csv_text($data->well_location);
             $ivr_csv .= ',"="' . $this->_csv_text($data->phone_number) . '""';
             $ivr_csv .= ',' . $this->_csv_text($this->_code_numbers($data->well_working));
             $ivr_csv .= ',' . $this->_csv_text($data->time_received);
             $ivr_csv .= "\n";
         }
         // Output to browser
         header("Content-type: text/x-csv");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Disposition: attachment; filename=IVR_export_" . date("Y-m-d_H.i.s") . ".csv");
         header("Content-Length: " . strlen($ivr_csv));
         echo $ivr_csv;
         exit;
     }
     // _POST
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->template->content = new View('ivr_api/ivrapiexport');
         $this->template->content->title = Kohana::lang('ivr_api.export_ivr');
         $this->template->content->form_error = false;
     }
 }
开发者ID:rrbaker,项目名称:Ushahidi_IVR_API_Plugin,代码行数:53,代码来源:ivrapiexport.php

示例8: add_comment

 /**
  * add a comment
  */
 function add_comment()
 {
     $output = array();
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "reports_edit")) {
         $output['status'] = 'error';
         $output['messages'] = array('error' => 'you don\'t have permissions to do this');
         echo json_encode($output);
         exit;
     }
     //export that data
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         //	 Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('reporter_name', 'length[0,255]');
         $post->add_rules('reporter_position', 'length[0,255]');
         $post->add_rules('other_text', 'length[0,255]');
         $post->add_rules('refered_to', 'length[0,255]');
         $post->add_rules('refered_to_date', 'date_mmddyyyy');
         $post->add_rules('entered_by', 'length[0,255]');
         $post->add_rules('added_by_date', 'date_mmddyyyy');
         if ($post->validate()) {
             $comment = ORM::factory('ivrapi_data_comments');
             //get the data
             $comment->reporter_name = $post['reporter_name'];
             $comment->reporter_position = $post['reporter_position'];
             $comment->summary = $post['summary'];
             $comment->tech_hand_pump = $post['tech_hand_pump'] == 'true' ? 1 : 0;
             $comment->tech_other = $post['tech_other'] == 'true' ? 1 : 0;
             $comment->water_qual = $post['water_qual'] == 'true' ? 1 : 0;
             $comment->water_table = $post['water_table'] == 'true' ? 1 : 0;
             $comment->mechanic_awol = $post['mechanic_awol'] == 'true' ? 1 : 0;
             $comment->mechanic_no_fix = $post['mechanic_no_fix'] == 'true' ? 1 : 0;
             $comment->financial = $post['financial'] == 'true' ? 1 : 0;
             $comment->vandalism = $post['vandalism'] == 'true' ? 1 : 0;
             $comment->call_error = $post['call_error'] == 'true' ? 1 : 0;
             $comment->unknown = $post['unknown'] == 'true' ? 1 : 0;
             $comment->other = $post['other'] == 'true' ? 1 : 0;
             $comment->other_text = $post['other_text'];
             $comment->action_taken = $post['action_taken'];
             $comment->refered_to = $post['refered_to'];
             $comment->refered_to_date = date('Y-m-d G:i:s', strtotime($post['refered_to_date']));
             $comment->entered_by = $post['entered_by'];
             $comment->added_on_date = date('Y-m-d G:i:s');
             $comment->ivr_data_id = $post['ivr_data_id'];
             $comment->save();
             $output['status'] = 'success';
             $view = View::factory('ivr_api/ivr_view_comments');
             $view->comment = $comment;
             //capture this into a variable;
             ob_start();
             $view->render(TRUE);
             $output['html'] = ob_get_contents();
             ob_end_clean();
             echo json_encode($output);
             exit;
         } else {
             //send out the errors
             $output['status'] = 'error';
             $errors = $post->errors();
             $error_val = "";
             $error_key = "";
             foreach ($errors as $key => $val) {
                 $error_val = $val;
                 $error_key = $key;
                 break;
             }
             //translate to more human readable
             if ($error_val == 'length') {
                 $error_val = Kohana::lang('ivr_api.comment_field_length');
             }
             $output['messages'] = Kohana::lang('ivr_api.comment_field') . ' "' . $error_key . '" ' . $error_val;
             echo json_encode($output);
             exit;
         }
     }
 }
开发者ID:rrbaker,项目名称:Ushahidi_IVR_API_Plugin,代码行数:82,代码来源:ivrapicomments.php

示例9: User_Model

 *
 * Changelog:
 * 2012-04-27:  MacKay - Initial release
 *
 * Developed by Etherton Technologies Ltd.
 */
?>



			<?php 
//see if the user we're dealing with can see reports
// If user doesn't have access, redirect to dashboard
if (isset($_SESSION['auth_user'])) {
    $user = new User_Model($_SESSION['auth_user']->id);
    $user_view_reports = admin::permissions($user, "reports_view");
    if (ORM::factory('enhancedmap_settings')->where('key', 'show_unapproved_frontend')->find()->value == 'true' and $user_view_reports) {
        ?>
			<!-- Show unapproved -->
	
				<ul id="<?php 
        echo $status_filter_id;
        ?>
" class="category-filters status-filters">
					<strong><?php 
        echo Kohana::lang('enhancedmap.status_filters');
        ?>
:</strong>
					<li>
						<a <?php 
        if ($show_unapproved) {
开发者ID:rjmackay,项目名称:enhancedmap,代码行数:31,代码来源:status_filter.php

示例10: upload

 public function upload()
 {
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "reports_upload")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->template->content = new View('admin/reports_upload');
         $this->template->content->title = 'Upload Reports';
         $this->template->content->form_error = false;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $errors = array();
         $notices = array();
         if (!$_FILES['csvfile']['error']) {
             if (file_exists($_FILES['csvfile']['tmp_name'])) {
                 if ($filehandle = fopen($_FILES['csvfile']['tmp_name'], 'r')) {
                     $importer = new ReportsImporter();
                     if ($importer->import($filehandle)) {
                         $this->template->content = new View('admin/reports_upload_success');
                         $this->template->content->title = 'Upload Reports';
                         $this->template->content->rowcount = $importer->totalrows;
                         $this->template->content->imported = $importer->importedrows;
                         $this->template->content->notices = $importer->notices;
                     } else {
                         $errors = $importer->errors;
                     }
                 } else {
                     $errors[] = Kohana::lang('ui_admin.file_open_error');
                 }
             } else {
                 $errors[] = Kohana::lang('ui_admin.file_not_found_upload');
             }
         } else {
             $errors[] = $_FILES['csvfile']['error'];
         }
         if (count($errors)) {
             $this->template->content = new View('admin/reports_upload');
             $this->template->content->title = Kohana::lang('ui_admin.upload_reports');
             $this->template->content->errors = $errors;
             $this->template->content->form_error = 1;
         }
     }
 }
开发者ID:rootz,项目名称:Ushahidi_Web,代码行数:44,代码来源:reports.php

示例11: show_ivr_history

 /**
  * Creates the view of the IVR history
  */
 public function show_ivr_history()
 {
     //get the incident_id
     $id = Event::$data;
     //make sure it's a valid id
     if ($id == null || $id == "0" || $id == false) {
         return;
     }
     //get the IVR data that is associated with this incident
     $ivr_datas = ORM::factory('ivrapi_data')->where('incident_id', $id)->orderby('time_received', 'DESC')->find_all();
     //get the comments that go along with this IVR data
     //start by getting the IDs of all the IVR items into a string
     $in_str = "";
     $i = 0;
     foreach ($ivr_datas as $data) {
         $i++;
         if ($i > 1) {
             $in_str .= ',';
         }
         $in_str .= $data->id;
     }
     $comments = array();
     if ($in_str != "") {
         //get the database prefix:
         $table_prefix = Kohana::config('database.default.table_prefix');
         //make up some SQL
         $sql = 'SELECT * FROM ' . $table_prefix . 'ivrapi_data_comments as comments ';
         $sql .= 'WHERE ivr_data_id IN (' . $in_str . ') ';
         $sql .= 'ORDER BY ivr_data_id, added_on_date';
         $db = new Database();
         $query = $db->query($sql);
         //now put all of this into useful arrays
         foreach ($query as $comment) {
             if (!isset($comments[$comment->ivr_data_id])) {
                 $comments[$comment->ivr_data_id] = array();
             }
             $comments[$comment->ivr_data_id][] = $comment;
         }
     }
     //if there's no history, then bounce
     if (count($ivr_datas) == 0) {
         return;
     }
     $view = View::factory('ivr_api/ivr_view');
     $view->can_comment = admin::permissions(new User_Model($_SESSION['auth_user']->id), "reports_edit");
     $view->ivr_datas = $ivr_datas;
     $view->comments = $comments;
     $view->render(TRUE);
 }
开发者ID:rrbaker,项目名称:Ushahidi_IVR_API_Plugin,代码行数:52,代码来源:Ushahidi_IVR_API_Plugin.php

示例12: index

 /**
  * Lists the reports.
  * @param int $page
  */
 function index($page = 1)
 {
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "reports_view")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     $this->template->content = new View('adminmap/adminmap_reports');
     $this->template->content->title = Kohana::lang('ui_admin.reports');
     if (!empty($_GET['status'])) {
         $status = $_GET['status'];
         if (strtolower($status) == 'a') {
             $filter = 'incident.incident_active = 0';
         } elseif (strtolower($status) == 'v') {
             $filter = 'incident.incident_verified = 0';
         } else {
             $status = "0";
             $filter = '1=1';
         }
     } else {
         $status = "0";
         $filter = "1=1";
     }
     // check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('incident_id.*', 'required', 'numeric');
         if ($post->validate()) {
             if ($post->action == 'a') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     if ($update->loaded == true) {
                         if ($update->incident_active == 0) {
                             $update->incident_active = '1';
                         } else {
                             $update->incident_active = '0';
                         }
                         // Tag this as a report that needs to be sent out as an alert
                         if ($update->incident_alert_status != '2') {
                             // 2 = report that has had an alert sent
                             $update->incident_alert_status = '1';
                         }
                         $update->save();
                         $verify = new Verify_Model();
                         $verify->incident_id = $item;
                         $verify->verified_status = '1';
                         $verify->user_id = $_SESSION['auth_user']->id;
                         // Record 'Verified By' Action
                         $verify->verified_date = date("Y-m-d H:i:s", time());
                         $verify->save();
                         // Action::report_approve - Approve a Report
                         Event::run('ushahidi_action.report_approve', $update);
                     }
                 }
                 $form_action = strtoupper(Kohana::lang('ui_admin.approved'));
             } elseif ($post->action == 'u') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     if ($update->loaded == true) {
                         $update->incident_active = '0';
                         // If Alert hasn't been sent yet, disable it
                         if ($update->incident_alert_status == '1') {
                             $update->incident_alert_status = '0';
                         }
                         $update->save();
                         $verify = new Verify_Model();
                         $verify->incident_id = $item;
                         $verify->verified_status = '0';
                         $verify->user_id = $_SESSION['auth_user']->id;
                         // Record 'Verified By' Action
                         $verify->verified_date = date("Y-m-d H:i:s", time());
                         $verify->save();
                         // Action::report_unapprove - Unapprove a Report
                         Event::run('ushahidi_action.report_unapprove', $update);
                     }
                 }
                 $form_action = strtoupper(Kohana::lang('ui_admin.unapproved'));
             } elseif ($post->action == 'v') {
                 foreach ($post->incident_id as $item) {
                     $update = new Incident_Model($item);
                     $verify = new Verify_Model();
                     if ($update->loaded == true) {
                         if ($update->incident_verified == '1') {
                             $update->incident_verified = '0';
                             $verify->verified_status = '0';
                         } else {
                             $update->incident_verified = '1';
                             $verify->verified_status = '2';
                         }
                         $update->save();
//.........这里部分代码省略.........
开发者ID:huslage,项目名称:Ushahidi_Web,代码行数:101,代码来源:adminmap_reports.php

示例13: _add_all_reports_filter

 /**
  * Function: _add_all_reports_filter
  *
  * Description: This function adds a flag that'll cause the incident::get_incidents to show all reports.
  * Called as a result of the following event(s): ushahidi_filter.fetch_incidents_set_params
  *
  * Views:
  *
  * Results: sneaks a fast one in and bypasses Ushahidi's attempt to hide unapproved reports
  */
 public function _add_all_reports_filter()
 {
     //check if we're on the backend or not
     $on_backend = $this->_on_back_end();
     //see if the user we're dealing with can see reports
     // If user doesn't have access, redirect to dashboard
     if (isset($_SESSION['auth_user'])) {
         $user = new User_Model($_SESSION['auth_user']->id);
         $user_view_reports = admin::permissions($user, "reports_view");
     } else {
         $user_view_reports = false;
     }
     $params = Event::$data;
     //also check and see if we want to show maybe, online approved, or only unapproved, you never know.
     //but check against the settings first
     if (ORM::factory('enhancedmap_settings')->where('key', 'show_unapproved_backend')->find()->value == 'true' and $on_backend or ORM::factory('enhancedmap_settings')->where('key', 'show_unapproved_frontend')->find()->value == 'true' and !$on_backend and $user_view_reports) {
         if (isset($_GET['u']) and intval($_GET['u']) > 0) {
             $params["all_reports"] = TRUE;
             $show_unapproved = intval($_GET['u']);
             if ($show_unapproved == '1') {
                 array_push($params, '(i.incident_active = 1)');
             } else {
                 if ($show_unapproved == '2') {
                     array_push($params, '(i.incident_active = 0)');
                 }
             }
         }
     }
     //only show hidden cats if the user is on the backend
     if ($on_backend and ORM::factory('enhancedmap_settings')->where('key', 'show_hidden_categories_backend')->find()->value == 'true') {
         //also make it so you can see any categories, not just the visible ones
         $i = null;
         $found_it = false;
         foreach ($params as $key => $value) {
             if (!is_array($value) and strcmp($value, 'c.category_visible = 1') == 0) {
                 $found_it = true;
                 $i = $key;
                 break;
             }
         }
         if ($found_it) {
             unset($params[$i]);
         }
     }
     Event::$data = $params;
 }
开发者ID:rjmackay,项目名称:enhancedmap,代码行数:56,代码来源:enhancedmap.php


注:本文中的admin::permissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。