コード例 #1
0
ファイル: programuser.action.php プロジェクト: jamesmcq/elis
 /**
  * Determine whether the current user can unassign the user from the program.
  * @param int $programid The ID of the program.
  * @param int $userid The ID of the user (the assignee).
  * @return bool Whether the current user has permission.
  */
 protected function can_unassign($programid, $userid)
 {
     return curriculumstudent::can_manage_assoc($userid, $programid);
 }
コード例 #2
0
ファイル: programuser.table.php プロジェクト: jamesmcq/elis
 /**
  * Transforms each result.
  * @param array $row An array for a single result.
  * @return array The transformed result.
  */
 protected function results_row_transform(array $row)
 {
     $row = parent::results_row_transform($row);
     // Whether the user can unassign from the program at all.
     static $canunassignany = null;
     // Whether the user can unassin any user from the program.
     static $canunassignall = null;
     // If not already set, determine whether the user can do any unassigning.
     if ($canunassignany === null) {
         $canunassignany = curriculumpage::can_enrol_into_curriculum($this->programid);
     }
     // If not already set, determine whether the user can unassign anyone - but only if $canunassignany is true.
     if ($canunassignany === true && $canunassignall === null) {
         $cpage = new curriculumpage();
         if ($cpage->_has_capability('local/elisprogram:program_enrol', $this->programid)) {
             $canunassignall = true;
         }
     }
     // Set the 'canunassign' parameter for use in javascript.
     if ($canunassignall === true) {
         $row['canunassign'] = '1';
     } else {
         if ($canunassignany === true) {
             $row['canunassign'] = curriculumstudent::can_manage_assoc($row['element_id'], $this->programid) === true ? '1' : '0';
         } else {
             $row['canunassign'] = '0';
         }
     }
     return $row;
 }