示例#1
0
文件: story.php 项目: jelek92/Zebra
 public function submit()
 {
     $this->data['page']['title'] = "Submit new news story";
     $this->data['current_segment'] = "submit";
     if ($this->form_validation->run('story') !== FALSE) {
         if (logged_in()) {
             $title = $this->input->post('title');
             $slug = url_title($this->input->post('title'), '-', TRUE);
             $link = $this->input->post('link', '');
             $text = nl2br($this->input->post('text', ''));
             $field_data = array('user_id' => current_user_id(), 'title' => $title, 'slug' => $slug, 'external_link' => $link, 'description' => $text, 'upvotes' => 1);
             $insert = $this->story->insert($field_data);
             if ($insert) {
                 $this->load->model('user/user_model', 'user');
                 $this->user->add_story_vote_record(current_user_id(), $this->db->insert_id());
                 $this->user->increment_submission_count(current_user_id());
                 $this->session->set_flashdata('success', lang('submission_success'));
                 redirect('stories/new');
             }
         } else {
             $this->session->set_flashdata('error', lang('submission_login'));
             redirect(base_url());
         }
     } else {
         $this->parser->parse('add', $this->data);
     }
 }
示例#2
0
/**
 * Story Vote
 * 
 * A helper function for performing an upvote or
 * downvote on a particular story submission.
 * 
 * @param string $direction
 * @param int $story_id
 * @param int $reason_id
 * @return string
 * 
 */
function story_vote($direction = "up", $story_id = 0, $reason_id = 0)
{
    // Get the currently logged in user ID
    $user_id = current_user_id();
    $CI =& get_instance();
    $CI->load->model('vote/vote_model', 'vote');
    if (!$user_id) {
        return FALE;
    } else {
        if ($direction == 'up') {
            if (!story_upvoted($story_id, $user_id)) {
                rewind_story_vote('down', $story_id);
                return $CI->vote->cast_story_vote("up", $story_id, $user_id);
            } else {
                return FALSE;
            }
        } elseif ($direction == 'down') {
            if (!story_downvoted($story_id, $user_id)) {
                rewind_story_vote('up', $story_id);
                return $CI->vote->cast_story_vote("down", $story_id, $user_id, $reason_id);
            } else {
                return FALSE;
            }
        }
    }
}
示例#3
0
文件: comment.php 项目: jelek92/Zebra
 /**
  * Edit a singular comment
  * 
  * @param  integer $comment_id Comment to view
  * @return void
  */
 public function edit($comment_id)
 {
     $comment = $this->comment_model->get($comment_id);
     $user_id = current_user_id();
     // Make sure the comment exists
     if ($comment) {
         // Are we an admin or have permission to edit comments?
         if (is_admin() or user_can('edit_own_comments')) {
             // Are we an admin or the owner of the comment itself?
             if (is_admin() || $comment->user_id == $user_id) {
                 // Run form validation
                 if ($this->form_validation->run('edit_comment') == FALSE) {
                     $this->data['comment'] = $comment;
                     $this->parser->parse('edit_comment', $this->data);
                 } else {
                     $update = $this->comment_model->update_comment($comment->id, $comment->story_id, $user_id, $comment->parent_id, $this->input->post('comment'));
                     $this->parser->parse('edit_comment', $this->data);
                 }
             } else {
                 show_error("You do not have permission to edit this comment.", 500);
             }
         } else {
             show_error("You do not have permission to edit this comment.", 500);
         }
     } else {
         show_error("That comment doesn't exist", 404);
     }
 }
示例#4
0
 /** Creates a call, returns the id of the created call */
 public function create_call($participation_id)
 {
     $previous_call = $this->last_call($participation_id);
     $nr = empty($previous_call) ? 1 : $previous_call->nr + 1;
     $call = array('participation_id' => $participation_id, 'user_id' => current_user_id(), 'nr' => $nr, 'status' => CallStatus::CallStarted);
     $this->db->insert('call', $call);
     return $this->db->insert_id();
 }
示例#5
0
function calculate_average_submissions($user_id = 0)
{
    $CI =& get_instance();
    $CI->load->model('user/user_model', 'user');
    if ($user_id == 0) {
        $user_id = current_user_id();
    }
    return $CI->user->calculate_average_submissions($user_id);
}
 /**
  * 	Checks whether the current user is also the user for which the page is called.
  *  If not, this function will load a 'not authorized' page.
  */
 function correct_user($user_id)
 {
     if ($user_id != current_user_id()) {
         $CI =& get_instance();
         $data['error'] = lang('not_authorized');
         $CI->load->view('templates/error', $data);
         return FALSE;
     }
     return TRUE;
 }
示例#7
0
 /**
  * Saves a comment into the database
  * 
  * @param  integer $story_id The story submission ID
  * @param  integer $user_id  User that owns the comment
  * @param  integer $reply_id In reply to whom?
  * @param  string  $comment  The comment text
  * @return boolean
  */
 public function save_comment($story_id, $user_id, $reply_id, $comment)
 {
     $comment = nl2br($comment);
     $comment_id = $this->insert(array('user_id' => $user_id, 'story_id' => $story_id, 'parent_id' => $reply_id, 'comment' => $comment, 'upvotes' => 1));
     if ($comment_id) {
         $this->load->model('user/user_model', 'user');
         $this->user->add_comment_vote_record(current_user_id(), $comment_id);
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#8
0
 /** Specifies the content for the admin interface view. */
 public function index()
 {
     switch (current_role()) {
         case UserRole::Caller:
             $this->caller_interface(current_user_id());
             break;
         case UserRole::Leader:
             $this->leader_interface(current_user_id());
             break;
         case UserRole::Admin:
             $this->admin_interface();
             break;
         case UserRole::System:
             redirect('appointment');
             break;
         default:
             show_404();
             break;
     }
 }
示例#9
0
 /** Submits the username and password and redirects based on validation. */
 public function submit($language = L::Dutch)
 {
     // Login = NOT OK -> destroy session and return to login form
     if (!$this->validate($language)) {
         $this->session->sess_destroy();
         $this->index($language);
         return;
     } else {
         // Load language file
         reset_language(current_language());
         // If a Caller has not yet signed, send him to that form
         $user = $this->userModel->get_user_by_id(current_user_id());
         if ($user->needssignature && !$user->signed) {
             redirect('user/sign/');
         }
         // Otherwise, check if we have a referrer, if so, send to that page
         $referrer = $this->input->post('referrer');
         if ($referrer) {
             redirect($referrer);
         } else {
             redirect('welcome');
         }
     }
 }
    /**
     * Special table with participants that need to be called back
     */
    public function table_callback()
    {
        $experiment_ids = $this->callerModel->get_experiment_ids_by_caller(current_user_id());
        $this->datatables->select('CONCAT(participant.firstname, " ", participant.lastname) AS p, 
									name AS e, call_back_date, call_back_comment,
									participation.id AS id, participant_id, experiment_id', FALSE);
        $this->datatables->from('participation');
        $this->datatables->join('participant', 'participant.id = participation.participant_id');
        $this->datatables->join('experiment', 'experiment.id = participation.experiment_id');
        $this->datatables->join('call', 'call.participation_id = participation.id AND TIMESTAMPDIFF(MINUTE, call.timeend, participation.lastcalled) <= 1');
        $this->datatables->where('call.status', CallStatus::CallBack);
        if ($experiment_ids) {
            $this->datatables->where('experiment_id IN (' . implode(',', $experiment_ids) . ')');
        }
        $this->datatables->edit_column('p', '$1', 'participant_get_link_by_id(participant_id)');
        $this->datatables->edit_column('e', '$1', 'experiment_get_link_by_id(experiment_id)');
        $this->datatables->edit_column('call_back_date', '$1', 'output_date(call_back_date)');
        $this->datatables->edit_column('id', '$1', 'participation_callback_actions(id)');
        $this->datatables->unset_column('participant_id');
        $this->datatables->unset_column('experiment_id');
        echo $this->datatables->generate();
    }
示例#11
0
/**
 * Comment Vote
 * 
 * A helper function for performing an upvote or
 * downvote on a particular comment.
 * 
 * @param string $direction
 * @param int $comment_id
 * @param int $reason_id
 * @return string
 * 
 */
function comment_vote($direction = "up", $comment_id = 0, $reason_id = 0)
{
    // Get the currently logged in user ID
    $user_id = current_user_id();
    $CI =& get_instance();
    $CI->load->model('vote/vote_model', 'vote');
    if (!$user_id) {
        return lang('user_not_logged_in');
    } else {
        if ($direction == 'up') {
            if (!comment_upvoted($comment_id, $user_id)) {
                rewind_comment_vote("down", $comment_id);
                return $CI->vote->cast_comment_vote("up", $comment_id, $user_id);
            } else {
                return FALSE;
            }
        } elseif ($direction == 'down') {
            if (!comment_downvoted($comment_id, $user_id)) {
                rewind_comment_vote("up", $comment_id);
                return $CI->vote->cast_comment_vote("down", $comment_id, $user_id, $reason_id);
            } else {
                return FALSE;
            }
        }
    }
}
示例#12
0
 public function table()
 {
     $participant_ids = array();
     if (current_role() == UserRole::Caller) {
         $experiments = $this->callerModel->get_experiments_by_caller(current_user_id());
         foreach ($experiments as $experiment) {
             $find_p = $this->participantModel->find_participants($experiment);
             $part_p = $this->experimentModel->get_participants_by_experiment($experiment->id);
             $participant_ids = array_merge($participant_ids, get_object_ids($find_p));
             $participant_ids = array_merge($participant_ids, get_object_ids($part_p));
         }
     }
     if (current_role() == UserRole::Leader) {
         $experiments = $this->leaderModel->get_experiments_by_leader(current_user_id());
         foreach ($experiments as $experiment) {
             $part_p = $this->experimentModel->get_participants_by_experiment($experiment->id);
             $participant_ids = array_merge($participant_ids, get_object_ids($part_p));
         }
     }
     $this->datatables->select('CONCAT(firstname, " ", lastname) AS p, dateofbirth, dateofbirth as age, dyslexicparent, multilingual, phone, id, CONCAT(parentfirstname, " ", parentlastname)', FALSE);
     $this->datatables->from('participant');
     if (!is_admin()) {
         if (empty($participant_ids)) {
             $this->datatables->where('id', 0);
         } else {
             $this->datatables->where('id IN (' . implode(',', $participant_ids) . ')');
         }
     }
     $this->datatables->edit_column('p', '$1', 'participant_get_link_by_id(id)');
     $this->datatables->edit_column('dateofbirth', '$1', 'dob(dateofbirth)');
     $this->datatables->edit_column('age', '$1', 'age_in_months_and_days(age)');
     $this->datatables->edit_column('dyslexicparent', '$1', 'img_tick(dyslexicparent)');
     $this->datatables->edit_column('multilingual', '$1', 'img_tick(multilingual)');
     $this->datatables->edit_column('id', '$1', 'participant_actions(id)');
     echo $this->datatables->generate();
 }
示例#13
0
 function assign()
 {
     $lead_id = $this->request->route('id');
     $data['lead'] = $this->lead->getLeadDetails($lead_id);
     $sales_people = User::select('id', 'given_name', 'surname')->where('role', 3)->get()->toArray();
     $data['sales_people'][0] = 'Select User';
     foreach ($sales_people as $sales_person) {
         if ($sales_person['id'] != current_user_id()) {
             $data['sales_people'][$sales_person['id']] = $sales_person['given_name'] . ' ' . $sales_person['surname'];
         } else {
             $data['sales_people'][$sales_person['id']] = 'Assign to Self (' . $sales_person['given_name'] . ' ' . $sales_person['surname'] . ')';
         }
     }
     return view('system.lead.assign', $data);
 }
示例#14
0
            $errors[] = "File is too big. Maximum size is 1 KB. Make sure that " . "your zip file contains only your code files.";
        } else {
            $filename = basename($_FILES['uploadedfile']['name']);
            if (!ends_with($filename, ".zip") && !ends_with($filename, ".tgz") && !ends_with($filename, ".tar.gz")) {
                $errors[] = "Invalid file type. Must be zip, tgz, or tar.gz";
            }
        }
    }
    return $errors;
}
$submission_directory = "/home/contest/ai-contest/planet_wars/submissions/";
if (!logged_in_with_valid_credentials()) {
    header('Location: index.php');
    die;
}
$result = mysql_query("SELECT * FROM users WHERE user_id=" . current_user_id());
$userdata = mysql_fetch_assoc($result);
$sid = session_id();
$local_key = sha1($sid . $userdata['activation_code'] . $userdata['email']);
if ($local_key != $_POST['submit_key']) {
    die('Bad submission key found.');
}
// Uncomment the following line to turn off new submissions.
$errors[] = "Nuh-uh. The contest is over. No more submissions.";
if (count($errors) == 0) {
    if (has_recent_submission()) {
        $errors[] = "Sorry your last submission was too recent.";
    } else {
        $errors = upload_errors($errors);
    }
}
示例#15
0
 function changeStatus($application_id, $status)
 {
     ApplicationStatus::create(['status_id' => $status, 'date_created' => get_today_datetime(), 'application_id' => $application_id, 'updated_by' => current_user_id()]);
 }
示例#16
0
 })();
</script>
</head>
<body>
<div id="main">
<!-- <div id="wrapper"> -->
  <div id="header">
    <div class="grid">
    <h1>Google AI Challenge</h1>
    <h2>Organized by the University of Waterloo Computer Science Club and sponsored by Google</h2>
    <span id="sign">
      <?php 
if (logged_in_with_valid_credentials()) {
    ?>
        <a href="profile.php?user_id=<?php 
    echo current_user_id();
    ?>
">
          My Profile (<?php 
    echo htmlspecialchars(current_username());
    ?>
)
          </a> |
        <a href="logout.php">Sign Out</a>
      <?php 
} else {
    ?>
        <a href="login.php">Sign In</a> |
        <a href="register.php">Sign Up</a>
      <?php 
}
示例#17
0
 /**
  * Generates HTML Output for the calender tooltip
  * @param Participation $participation ID
  * @param Participant $participant
  * @param Experiment $experiment
  */
 private function generate_tooltip($participation, $participant, $experiment)
 {
     $exp_link = lang('experiment') . ': ';
     $exp_link .= experiment_get_link($experiment);
     $exp_link .= br();
     $part_link = lang('participant') . ': ';
     $part_link .= participant_get_link($participant);
     $part_link .= br();
     $loc_link = lang('location') . ': ';
     $loc_link .= location_get_link_by_id($experiment->location_id);
     $loc_link .= br();
     $user_link = '';
     if ($participation->user_id_leader) {
         $user_link .= lang('leader') . ': ';
         $user_link .= user_get_link_by_id($participation->user_id_leader);
         $user_link .= br();
     }
     $comment = '';
     if ($participation->calendar_comment) {
         $comment .= lang('comment') . ': ';
         $comment .= $participation->calendar_comment;
         $comment .= br();
     }
     // Show actions only if user the leader of this participation (or if user is admin/caller)
     $current_user_is_leader = is_leader() && $participation->user_id_leader != current_user_id();
     $participation_actions = $current_user_is_leader ? '' : '<center>' . participation_actions($participation->id) . '</center>';
     return addslashes($exp_link . $part_link . $loc_link . $user_link . $comment . $participation_actions);
 }
示例#18
0
 /**
  * Posts the data for a comment for a participant
  * @param integer $participant_id 
  * @return array
  */
 private function post_comment($participant_id)
 {
     $comment = $this->input->post('comment');
     if (empty($comment)) {
         return NULL;
     }
     $user_id = current_user_id();
     if (empty($user_id)) {
         $user_id = system_user_id();
     }
     return array('body' => $comment, 'participant_id' => $participant_id, 'user_id' => $user_id);
 }
示例#19
0
 function update_current_submission_status($new_status)
 {
     $submission_id = current_submission_id();
     if ($submission_id < 0) {
         print "<p>submission_id = " . $submission_id . "</p>";
         return FALSE;
     }
     $user_id = current_user_id();
     if ($user_id < 0) {
         print "<p>user_id = " . $user_id . "</p>";
         return FALSE;
     }
     $query = "UPDATE submissions SET status = " . $new_status . " WHERE submission_id = " . $submission_id . " AND user_id = " . $user_id;
     //print "<p>query = " . $query . "</p>";
     return mysql_query($query);
 }
示例#20
0
    }
    $query = "SELECT count(*) from countries where country_id=" . $id;
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    if ($row['count(*)'] > 0) {
        return True;
    }
    return False;
}
if (!logged_in_with_valid_credentials()) {
    die("Nice try.. but the bad robot WILL get you");
}
if (!array_key_exists('update_key', $_POST)) {
    die("Check key not found.");
}
$user_id = current_user_id();
$query = "SELECT email, activation_code FROM users WHERE user_id=" . $user_id;
$result = mysql_query($query);
if ($row = mysql_fetch_assoc($result)) {
    $sid = session_id();
    $update_key = $_POST['update_key'];
    $local_key = sha1($sid . $row['activation_code'] . $row['email']);
    if ($local_key != $update_key) {
        die("Bad update key found.");
    }
} else {
    die("User data query failed.");
}
if (array_key_exists('user_country', $_POST)) {
    $country_id = $_POST['user_country'];
    if (!check_valid_country($country_id)) {
 /**
  * This method creates an e-mail by referring to a view and replacing the variables. 
  * TODO: refactor to use less parameters (all in one array)?
  */
 function email_replace($view, $participant = NULL, $participation = NULL, $experiment = NULL, $testinvite = NULL, $comb_experiment = NULL, $auto = FALSE, $message = "", $language = L::Dutch)
 {
     $CI =& get_instance();
     $user = $CI->userModel->get_user_by_id(current_user_id());
     reset_language($language);
     $message_data = array();
     $message_data['auto'] = $auto;
     $message_data['message'] = $message;
     $message_data['combination'] = FALSE;
     $message_data['longitudinal'] = FALSE;
     $message_data['survey_link'] = FALSE;
     if ($user) {
         $message_data['user_username'] = $user->username;
         $message_data['user_email'] = $user->email;
     }
     if ($participant) {
         $message_data['name'] = name($participant);
         $message_data['name_first'] = $participant->firstname;
         $message_data['name_parent'] = parent_name($participant);
         $message_data['gender'] = gender_child($participant->gender);
         $message_data['gender_pos'] = gender_pos($participant->gender);
         $message_data['gender_plural'] = gender_sex($participant->gender) . 's';
         $message_data['phone'] = $participant->phone;
     }
     if ($participation) {
         $leader = $CI->userModel->get_user_by_id($participation->user_id_leader);
         $message_data['appointment'] = format_datetime($participation->appointment);
         if ($leader) {
             $message_data['leader_name'] = $leader->firstname;
         }
     }
     if ($experiment) {
         $location = $CI->locationModel->get_location_by_experiment($experiment);
         $message_data['exp_name'] = $experiment->name;
         $message_data['type'] = $experiment->type;
         $message_data['duration'] = $experiment->duration;
         $message_data['duration_total'] = $experiment->duration + INSTRUCTION_DURATION;
         $message_data['description'] = $experiment->description;
         $message_data['location'] = sprintf('%s (%s)', $location->name, $location->roomnumber);
         $message_data['caller_contacts'] = extract_callers($experiment, $comb_experiment);
     }
     if ($comb_experiment) {
         $location = $CI->locationModel->get_location_by_experiment($comb_experiment);
         $comb_participation = $CI->participationModel->get_participation($comb_experiment->id, $participant->id);
         $relation = $CI->relationModel->get_relation_by_experiments($experiment->id, $comb_experiment->id);
         $message_data['combination'] = $relation->relation === RelationType::Combination;
         $message_data['longitudinal'] = $relation->relation === RelationType::Prerequisite;
         $message_data['comb_exp_name'] = $comb_experiment->name;
         $message_data['comb_type'] = $comb_experiment->type;
         $message_data['comb_duration'] = $comb_experiment->duration;
         $message_data['comb_duration_total'] = $comb_experiment->duration + INSTRUCTION_DURATION;
         $message_data['comb_description'] = $comb_experiment->description;
         $message_data['comb_location'] = sprintf('%s (%s)', $location->name, $location->roomnumber);
         $message_data['comb_appointment'] = format_datetime($comb_participation->appointment);
     }
     if ($participant && $experiment) {
         $data = get_min_max_days($participant, $experiment);
         $message_data['min_date'] = format_date($data['min_date_js']);
         $message_data['max_date'] = format_date($data['max_date_js']);
     }
     if ($testinvite) {
         $test = $CI->testInviteModel->get_test_by_testinvite($testinvite);
         $testsurvey = $CI->testInviteModel->get_testsurvey_by_testinvite($testinvite);
         $message_data['survey_name'] = testsurvey_name($testsurvey);
         $message_data['survey_link'] = survey_link($testsurvey->limesurvey_id, $testinvite->token);
         $message_data['results_link'] = results_link($test->code, $testinvite->token);
         $message_data['whennr'] = $testsurvey->whennr;
     }
     return $CI->load->view($view, $message_data, TRUE);
 }
 /** Releases the lock of the participation */
 public function count_to_be_called_back($call_back_date = NULL)
 {
     $experiment_ids = $this->callerModel->get_experiment_ids_by_caller(current_user_id());
     $this->db->join('participant', 'participant.id = participation.participant_id');
     $this->db->join('experiment', 'experiment.id = participation.experiment_id');
     $this->db->join('call', 'call.participation_id = participation.id AND TIMESTAMPDIFF(MINUTE, call.timeend, participation.lastcalled) <= 1');
     $this->db->where('call.status', CallStatus::CallBack);
     if ($experiment_ids) {
         $this->db->where('experiment_id IN (' . implode(',', $experiment_ids) . ')');
     }
     if ($call_back_date) {
         $this->db->where('call_back_date', $call_back_date);
     }
     return $this->db->count_all_results('participation');
 }
示例#23
0
}
$rank = $rank == NULL ? "N/A. No ranking available" : $rank;
$username = htmlentities($userdata["username"]);
$created = $userdata["created"];
$country_id = htmlentities($userdata["country_id"]);
$country_name = htmlentities($userdata["country_name"]);
$country_name = $country_name == NULL ? "Unknown" : htmlentities($country_name);
$flag_filename = $userdata["flag_filename"];
$flag_filename = $flag_filename == NULL ? "" : "<img alt=\"{$country_name}\" width=\"16\" height=\"11\" title=\"{$country_name}\" src=\"flags/{$flag_filename}\" />";
$org_id = htmlentities($userdata["org_id"]);
$org_name = htmlentities($userdata["org_name"]);
$bio = htmlentities($userdata["bio"]);
if ($org_name == NULL) {
    $org_name = "None";
}
if (logged_in_with_valid_credentials() && current_user_id() == $user_id) {
    $logged_in = true;
    $sid = session_id();
    $update_key = sha1($sid . $userdata["activation_code"] . $userdata["email"]);
} else {
    $logged_in = false;
}
if (!$userresult) {
    echo "<p>Invalid User ID</p>";
} else {
    echo "    <h2>Profile for {$username}</h2>";
    if ($logged_in) {
        echo <<<EOT
    <script>
    function toggle_change_org() {
       if (document.getElementById('orgchange').style.display == 'none') {
示例#24
0
 function dataTablePagination(Request $request, array $select = array(), $unassigned_only = false)
 {
     if (is_array($select) and count($select) < 1) {
         $select = "*";
     }
     $take = $request->input('length') > 0 ? $request->input('length') : 10;
     $start = $request->input('start') > 0 ? $request->input('start') : 0;
     $search = $request->input('search');
     $search = $search['value'];
     $order = $request->input('order');
     $column_id = $order[0]['column'];
     $columns = $request->input('columns');
     $orderColumn = $columns[$column_id]['data'];
     $orderdir = $order[0]['dir'];
     $lead = array();
     $query = $this->select($select)->with('loan')->first();
     if ($orderColumn != '' and $orderdir != '') {
         $query = $query->orderBy($orderColumn, $orderdir);
     }
     if ($search != '') {
         $query = $query->where('domain', 'LIKE', "%{$search}%")->orwhere('email', 'LIKE', "%{$search}%");
     }
     if (!current_user()->isSuperAdmin) {
         $query = $query->where('added_by_users_id', current_user_id());
     }
     $lead['total'] = $query->count();
     $query->skip($start)->take($take);
     if ($unassigned_only == true) {
         $query = $query->where('status', 0);
     }
     $data = $query->get();
     foreach ($data as $key => &$value) {
         $client = Client::find($value->ex_clients_id);
         if ($value->status == 1) {
             $meeting_date = ClientLeadAssign::where('ex_leads_id', $value->id)->first()->meeting_datetime;
             $meeting_date = format_datetime($meeting_date);
         } else {
             $meeting_date = "Not Assigned Yet <a class = 'btn btn-primary btn-xs' href =" . url('system/lead/assign', $value->id) . ">Assign Now</a>";
         }
         $phone_number = $client->currentPhone();
         $value->client = $client->given_name . " " . $client->surname;
         $value->preferred_name = $client->preferred_name;
         $value->phone_number = $phone_number;
         $value->loan_type = $value->loan->loan_type;
         $value->meeting_date = $meeting_date;
         $value->actual_status = $value->status;
         $value->amount = $value->loan->amount;
         $value->status = $value->status == 0 ? '<span class="label label-danger">Unassigned</span>' : '<span class="label label-success">Assigned</span>';
     }
     $lead['data'] = $data->toArray();
     $json = new \stdClass();
     $json->draw = $request->input('draw') > 0 ? $request->input('draw') : 1;
     $json->recordsTotal = $lead['total'];
     $json->recordsFiltered = $lead['total'];
     $json->data = $lead['data'];
     return $json;
 }
示例#25
0
function current_user()
{
    return new User(current_user_id());
}
示例#26
0
        echo anchor('login/switch_to/leader', lang('login_leader'));
        echo " | ";
    }
    if ((user_role() === UserRole::Admin || user_role() === UserRole::Leader) && !is_caller()) {
        echo anchor('login/switch_to/caller', lang('login_caller'));
        echo " | ";
    }
    echo anchor('login/logout', lang('logout'));
    ?>
		</div>
		<?php 
}
?>

		<?php 
if (current_user_id() == 0) {
    ?>
		<div
			class="pure-menu pure-menu-open pure-menu-horizontal pure-menu-custom">
			<a href="" class="pure-menu-heading"><?php 
    echo lang('babylab');
    ?>
 </a>
			<?php 
    $english = !isset($language) || $language === L::English;
    $menu = array(anchor($english ? 'login' : 'inloggen', lang('login')), anchor($english ? 'forgot_password' : 'wachtwoord_vergeten', lang('forgot_password')), anchor($english ? 'register' : 'registreren', lang('reg_user')), anchor($english ? 'signup' : 'aanmelden', lang('reg_pp')), anchor($english ? 'selfservice' : 'selfservice', lang('selfservice')), anchor($english ? 'inloggen' : 'login', '<em>' . ($english ? 'Nederlands' : 'English') . '</em>'));
    echo ul($menu);
    ?>
		</div>
		<?php 
}
示例#27
0
 /**
  * Signs the contract.
  */
 public function sign_submit()
 {
     // Set current time as signature time
     $user = array('needssignature' => FALSE, 'signed' => input_datetime());
     $this->userModel->update_user(current_user_id(), $user);
     // Redirect to welcome page
     flashdata(lang('signed'));
     redirect('welcome');
 }
示例#28
0
 /** Specifies the contents of the edit experiment page */
 public function edit($experiment_id)
 {
     if (is_leader() && !$this->leaderModel->is_leader_for_experiment(current_user_id(), $experiment_id)) {
         show_error("You are not a leader for this experiment.");
     }
     $experiment = $this->experimentModel->get_experiment_by_id($experiment_id);
     $leaders = array_merge($this->userModel->get_all_leaders(), $this->userModel->get_all_admins());
     $callers = $this->userModel->get_all_users();
     $experiments = $this->experimentModel->get_all_experiments(TRUE, $experiment_id);
     $data['page_title'] = lang('edit_experiment');
     $data['action'] = 'experiment/edit_submit/' . $experiment_id;
     $data = add_fields($data, 'experiment', $experiment);
     $data['date_start'] = output_date($experiment->date_start, TRUE);
     $data['date_end'] = output_date($experiment->date_end, TRUE);
     $data['locations'] = $this->locationModel->get_all_locations();
     $data['callers'] = caller_options($callers);
     $data['leaders'] = leader_options($leaders);
     $data['experiments'] = experiment_options($experiments);
     $data['location_id'] = $this->locationModel->get_location_by_experiment($experiment)->id;
     $data['current_caller_ids'] = $this->callerModel->get_caller_ids_by_experiment($experiment_id);
     $data['current_leader_ids'] = $this->leaderModel->get_leader_ids_by_experiment($experiment_id);
     $data['current_prerequisite_ids'] = $this->relationModel->get_relation_ids_by_experiment($experiment_id, RelationType::Prerequisite);
     $data['current_exclude_ids'] = $this->relationModel->get_relation_ids_by_experiment($experiment_id, RelationType::Excludes);
     $data['current_combination_ids'] = $this->relationModel->get_relation_ids_by_experiment($experiment_id, RelationType::Combination);
     $this->load->view('templates/header', $data);
     $this->load->view('experiment_edit_view', $data);
     $this->load->view('templates/footer');
 }
示例#29
0
 /** Posts the data for a comment */
 private function post_comment($participant_id)
 {
     return array('body' => $this->input->post('comment'), 'participant_id' => $participant_id, 'user_id' => current_user_id());
 }
示例#30
0
 function dataTablePagination(Request $request, array $select = array())
 {
     if (is_array($select) and count($select) < 1) {
         $select = "*";
     }
     $take = $request->input('length') > 0 ? $request->input('length') : 10;
     $start = $request->input('start') > 0 ? $request->input('start') : 0;
     $search = $request->input('search');
     $search = $search['value'];
     $order = $request->input('order');
     $column_id = $order[0]['column'];
     $columns = $request->input('columns');
     $orderColumn = $columns[$column_id]['data'];
     $orderdir = $order[0]['dir'];
     $client = array();
     $query = $this->select($select);
     if ($orderColumn != '' and $orderdir != '') {
         $query = $query->orderBy($orderColumn, $orderdir);
     }
     if ($search != '') {
         $query = $query->where('domain', 'LIKE', "%{$search}%")->orwhere('email', 'LIKE', "%{$search}%");
     }
     //if not super admin
     if (!current_user()->isSuperAdmin) {
         $query = $query->where('added_by_users_id', current_user_id());
     }
     $client['total'] = $query->count();
     $query->skip($start)->take($take);
     $data = $query->get();
     foreach ($data as $key => &$value) {
         $value->fullname = $value->given_name . " " . $value->surname;
         $value->DT_RowId = "row-" . $value->id;
         $phone = ClientPhone::where('ex_clients_id', $value->id)->where('is_current', 1)->with('phone')->first();
         $value->phone = !empty($phone) ? $phone->phone->number : '';
     }
     $client['data'] = $data->toArray();
     $json = new \stdClass();
     $json->draw = $request->input('draw') > 0 ? $request->input('draw') : 1;
     $json->recordsTotal = $client['total'];
     $json->recordsFiltered = $client['total'];
     $json->data = $client['data'];
     return $json;
 }