Ejemplo n.º 1
0
 /**
  * Unassign the usersets from the user.
  *
  * @param array $elements An array containing information on usersets to unassign from the user.
  * @param bool $bulkaction Whether this is a bulk-action or not.
  * @return array An array to format as JSON and return to the Javascript.
  */
 protected function _respond_to_js(array $elements, $bulkaction)
 {
     global $DB;
     $userid = required_param('id', PARAM_INT);
     // Permissions.
     $upage = new userpage();
     if ($upage->_has_capability('local/elisprogram:user_view', $userid) !== true) {
         return array('result' => 'fail', 'msg' => get_string('not_permitted', 'local_elisprogram'));
     }
     foreach ($elements as $usersetid => $label) {
         if ($this->can_unassign($userid, $usersetid) === true) {
             $assignrec = $DB->get_record(clusterassignment::TABLE, array('userid' => $userid, 'clusterid' => $usersetid));
             if (!empty($assignrec) && $assignrec->plugin === 'manual') {
                 $usertrack = new clusterassignment($assignrec);
                 $usertrack->delete();
             }
         }
     }
     return array('result' => 'success', 'msg' => 'Success');
 }
Ejemplo n.º 2
0
 /**
  * Determine whether the current user has permissions to view the link to a
  * user's individual user report page
  */
 function can_do_default()
 {
     global $USER;
     //obtain the target user's PM user id
     $id = $this->required_param('userid', PARAM_INT);
     //obtain the target user's PM user id
     $cmuserid = cm_get_crlmuserid($USER->id);
     if ($cmuserid != 0 && $cmuserid == $id) {
         //looking at your own report, and you have a PM user id
         return true;
     }
     //regular permissions check
     // TODO: Ugly, this needs to be overhauled
     $upage = new userpage();
     return $upage->_has_capability('local/elisreports:view', $id);
 }