function handlePOSTPageSubmit($request_data)
 {
     global $error_msg;
     //    echo '<pre>'.print_r($request_data,1).'</pre>';
     if (isset($request_data['form_data'])) {
         try {
             foreach ($request_data['form_data'] as $id => $act_data) {
                 $msg = null;
                 if ($id == 'new' && !empty($act_data['points'])) {
                     if ($this->validateFormData($act_data, &$msg)) {
                         $activity = new ActivityType($act_data['title'], $act_data['description'], $act_data['type'], $act_data['points']);
                         $activity->save();
                     } else {
                         throw new DynamicPageException($msg);
                     }
                 }
                 if ($id != 'new') {
                     if ($this->validateFormData($act_data, &$msg)) {
                         $activity = new ActivityType($act_data['title'], $act_data['description'], $act_data['type'], $act_data['points']);
                         $activity->id = $act_data['id'];
                         if (isset($request_data['submit_delete']) && isset($act_data['selected'])) {
                             $activity->delete();
                         } else {
                             $activity->save();
                         }
                     } else {
                         throw new DynamicPageException($msg);
                     }
                 }
             }
         } catch (DynamicPageException $e) {
             $error_msg = $e->getMessage();
         }
         unset($request_data['form_data']);
         $this->set_inner_template('default_inner.tpl');
         // initial template
         $activities = ActivityType::get_activity_types();
         $this->inner_HTML = $this->generate_inner_html(array('page_id' => $this->page_id, 'activities' => $activities));
     }
 }
 /**
  *Static Function to save activity performed by user in activity_log and in user_popularity his popularity according to his activities weightage, this function has a single query for insert and update if same login_id exists in table user_popularity
  *@param string $login_id to have present login user id
  *@param string $type is activity performed by user it should be present in array in api_constant
  *@param string $object is id of Group,Network,Album or Friend where ever is activity performed
  *@param string $extra is serialized description about activity performed
  */
 public static function save($login_id, $type, $object, $extra = NULL, $datetime = NULL, $points = 0)
 {
     Logger::log("Enter: function Activities::save");
     if (empty($type) || empty($object) || empty($login_id)) {
         Logger::log("Throwing exception");
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required parameter missing");
     }
     $time = $datetime ? $datetime : time();
     $activity_weightage = $points > 0 ? $points : ActivityType::get_points_for_activity($type);
     if ($activity_weightage !== false) {
         $sql = "INSERT INTO {activity_log} (type, subject, object, extra, status, time) VALUES(?, ?, ?, ?, ?, ?)";
         $data = array($type, $login_id, $object, $extra, 'new', $time);
         $res = Dal::query($sql, $data);
     } else {
         Logger::log("Throwing exception");
         throw new PAException(ACTIVITY_TYPE_NOT_EXIST, "Activity type not exist");
     }
     $sql = "INSERT INTO {user_popularity} (user_id, popularity, time) VALUES (" . $login_id . ", " . $activity_weightage . ", " . $time . ") ON DUPLICATE KEY UPDATE  popularity = (popularity + " . $activity_weightage . " ), time = " . $time;
     $res = Dal::query($sql);
     Logger::log("Exit: function Activities::save");
 }
Ejemplo n.º 3
0
 /**
  * @param array $data Parameters:
  *                    - group (integer)
  *                    - roles (list of roles)
  */
 public function __construct($data, $cron = false)
 {
     require_once 'group.php';
     parent::__construct($data, $cron);
     $members = group_get_member_ids($this->group, isset($this->roles) ? $this->roles : null, $this->deletedgroup);
     if (!empty($members)) {
         $this->users = activity_get_users($this->get_id(), $members);
     }
 }
Ejemplo n.º 4
0
     $url = "students/guardians/view";
     $guardian = Guardians::model()->findByAttributes(array('uid' => $feed->initiator_id));
     $id = $guardian->id;
 }
 if (sizeof($roles) == 1 and $role->name == 'student') {
     $url = "/students/students/view";
     $student = Students::model()->findByAttributes(array('uid' => $feed->initiator_id));
     $id = $student->id;
 }
 if (sizeof($roles) == 1 and $role->name == 'teacher') {
     $url = "employees/employees/view";
     $teacher = Employees::model()->findByAttributes(array('uid' => $feed->initiator_id));
     $id = $teacher->id;
 }
 // End Generate appropriate url and id
 $feed_type = ActivityType::model()->findByAttributes(array('id' => $feed->activity_type));
 // Determine the css class
 if ($feed->activity_type == 1) {
     $activity_class = "a_feed_login";
 } elseif ($feed->activity_type == 2) {
     $activity_class = "a_feed_logout";
 } elseif (in_array($feed->activity_type, array(3, 8, 11, 17, 20, 23))) {
     $activity_class = "a_feed_create";
 } elseif (in_array($feed->activity_type, array(4, 9, 12, 18, 21, 24, 27))) {
     $activity_class = "a_feed_edit";
 } elseif (in_array($feed->activity_type, array(5, 10, 13, 19, 22, 25))) {
     $activity_class = "a_feed_delet";
 } else {
     $activity_class = "a_feed_create";
 }
 // END determine the css class
Ejemplo n.º 5
0
 /**
  * @param array $data Parameters:
  *                    - subject (string)
  *                    - message (string)
  *                    - group (integer)
  *                    - roles (list of roles)
  */
 public function __construct($data, $cron = false)
 {
     require_once 'group.php';
     parent::__construct($data, $cron);
     $this->groupinfo = get_record('group', 'id', $this->group);
     $members = group_get_member_ids($this->group, isset($this->roles) ? $this->roles : null);
     $this->users = activity_get_users($this->get_id(), $members);
     if ($this->submittedview) {
         $this->viewinfo = get_record('view', 'id', $this->submittedview);
         $this->viewinfo->ownername = display_name($this->viewinfo->owner);
         $this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->submittedview;
     }
 }
Ejemplo n.º 6
0
 public function __construct($data, $cron = false)
 {
     parent::__construct($data, $cron);
     if (!($this->viewinfo = get_record_sql('SELECT u.*, v.title FROM {usr} u
                                      JOIN {view} v ON v.owner = u.id
                                      WHERE v.id = ?', array($this->view)))) {
         if (!empty($this->cron)) {
             // probably deleted already
             return;
         }
         throw new ViewNotFoundException(get_string('viewnotfound', 'error', $this->view));
     }
     $this->url = get_config('wwwroot') . 'view/view.php?id=' . $this->view;
     $this->users = array_diff_key(activity_get_viewaccess_users($this->view, $this->owner, $this->get_id()), $this->oldusers);
 }