예제 #1
0
function can_upload($session)
{
    if ($session['authenticator']) {
        $auth = $session['authenticator'];
        $reason_session =& get_reason_session();
        $username = $reason_session->get("username");
        if (isset($_REQUEST['user_id']) && !empty($_REQUEST['user_id'])) {
            $username = $reason_session->get('username');
            $param_cleanup_rules = array('user_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')));
            $cleanRequest = array_merge($_REQUEST, carl_clean_vars($_REQUEST, $param_cleanup_rules));
            $nametag = $cleanRequest['user_id'];
            $id = get_user_id($username);
            if (reason_user_has_privs($id, 'pose_as_other_user')) {
                $user = new Entity($nametag);
                $username = $user->get_value("name");
            }
        }
        if ($auth['file']) {
            require_once $auth['file'];
        }
        $args = array_merge(array($username), $auth['arguments']);
        if (!call_user_func_array($auth['callback'], $args)) {
            return false;
        }
    }
    return true;
}
 public function get_value($col, $refresh = true)
 {
     $custom_getter = 'get_value_' . $col;
     if (method_exists($this, $custom_getter)) {
         return $this->{$custom_getter}($refresh);
     } else {
         return parent::get_value($col, $refresh);
     }
 }
예제 #3
0
 /**
  * An export function which displays title, intro, publication/event
  * titles and dates, with events grouped by month.
  * 
  * Output looks like:
  * <code>
  * <h1>A Newsletter Title</h1>
  * <p>A newsletter description blah blah</p>
  * <h2>Recent News</h2>
  * <h3>The name of a publication</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010  9:23 am)</li>
  * 	<li><a target="_blank" href="some_story_url">A post</a> (Wed, May 19 2010  9:23 am)</li>
  * </ul>
  * <h2>Upcoming Events</h2>
  * <h3>April 2010</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, Apr 15 2010)</li>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, Apr 16 2010)</li>
  * </ul>
  * <h3>May 2010</h3>
  * <ul>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Thu, May 15 2010)</li>
  * 	<li><a target="_blank" href="some_event_url">An event</a> (4:30 pm on Fri, May 16 2010)</li>
  * </ul>
  * </code>
  * 
  * @param array the data to be transformed.
  * @return array the transformed data
  */
 function _export_headings_only_events_by_month($data)
 {
     $output = "";
     if ($data['info']['title']) {
         $output = '<h1>' . $data['info']['title'] . '</h1>';
     }
     if ($data['info']['intro']) {
         $output .= '<p>' . $data['info']['intro'] . '</p>';
     }
     if (!empty($data['pubs'])) {
         $output .= "<h2>Recent News</h2>";
         foreach ($data['pubs'] as $pub_id => $pub_posts) {
             $pub_ent = new Entity($pub_id);
             $output .= '<h3>' . $pub_ent->get_value('name') . '</h3>';
             $output .= "<ul>";
             foreach ($pub_posts as $pub_post) {
                 $output .= '<li><a target="_blank" href="' . $data['info']['urls'][$pub_id] . "?story_id=" . $pub_post->get_value('id') . '">' . $pub_post->get_value('name') . '</a> (' . date("D, M j Y  g:i a", strtotime($pub_post->get_value('datetime'))) . ')</li>';
             }
             $output .= "</ul>";
         }
     }
     if (!empty($data['events'])) {
         $output .= "<h2>Upcoming Events</h2>";
         foreach ($data['events'] as $day => $events) {
             $events_by_month[date("M-Y", strtotime($day))][$day] = $events;
         }
         foreach ($events_by_month as $month => $day) {
             $output .= "<h3>" . date("F Y", strtotime($month)) . "</h3>";
             $output .= "<ul>";
             foreach ($day as $day => $events) {
                 foreach ($events as $event) {
                     $eHelper = new EventHelper();
                     @$eHelper->set_page_link($event);
                     $eventURL = $event->get_value('url') . date("Y-m-d", strtotime($day));
                     $output .= '<li><a target="_blank" href="' . $eventURL . '">' . $event->get_value('name') . '</a> (' . date("D, M j", strtotime($day)) . " at " . date("g:i a", strtotime(preg_replace('/^.*[^ ] /', '', $event->get_value('datetime')))) . ')</li>';
                 }
             }
             $output .= "</ul>";
         }
     }
     return tidy($output);
 }