PHP User::createCourseStatus Examples

PHP User::createCourseStatus - 3 examples found. These are the top rated real world PHP examples of User::createCourseStatus extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * Add Course to an user
  *
  * @param string $userId UserID in our System (Attention: NOT the externalID)
  * @param string $courseID CourseID
  * @param string $status The Status the user wants to have in given course.
  * @return true if user is logged in
  */
 public function createCourseStatus($userId, $courseId, $status)
 {
     global $databaseURI;
     $data = User::encodeUser(User::createCourseStatus($userId, $courseId, $status));
     $url = "{$databaseURI}/coursestatus";
     $message = null;
     http_post_data($url, $data, true, $message);
     ///Logger::Log("create_user_status_url: ".$url, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     ///Logger::Log("create_user_status_message: ".$message, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     ///Logger::Log("create_user_status_data: ".$data, LogLevel::DEBUG, false, dirname(__FILE__) . '/../../auth.log');
     return $message == "201";
 }
Example #2
0
         $revokeRightsNotifications[] = MakeNotification("error", Language::Get('main', 'noSelectedUser', $langTemplate));
     }
 } elseif ($_POST['action'] == "AddUser") {
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkIntegerForKey('rights', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidCourseStatus', $langTemplate), array('min' => 0, 'max' => 2));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $userName = $foundValues['userName'];
         $rights = $foundValues['rights'];
         $URL = $databaseURI . '/user/user/' . $userName;
         $user = http_get($URL, true);
         $user = json_decode($user, true);
         if (isset($user['id'])) {
             $userId = $user['id'];
             $newUser = User::createCourseStatus($userId, $cid, $rights);
             $newUser = User::encodeUser($newUser);
             $URL = $databaseURI . '/coursestatus';
             http_post_data($URL, $newUser, true, $message);
             if ($message == "201") {
                 $addUserNotifications[] = MakeNotification('success', Language::Get('main', 'successAddUser', $langTemplate));
             } else {
                 $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'errorAddUser', $langTemplate));
             }
         } else {
             $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'invalidUserId', $langTemplate));
         }
     } else {
         if (!isset($addUserNotifications)) {
             $addUserNotifications = array();
         }
Example #3
0
         $userName = cleanInput($_POST['userName']);
         // extracts the userID
         $URI = $databaseURI . "/user/user/{$userName}";
         $user_data = http_get($URI, true);
         $user_data = json_decode($user_data, true);
         // sets admin rights for the user
         if (empty($user_data)) {
             $notifications[] = MakeNotification("error", Language::Get('main', 'invalidUserId', $langTemplate));
         } else {
             $userID = $user_data['id'];
             $status = 3;
             $data = User::encodeUser(User::createCourseStatus($userID, $courseID, $status));
             $url = $databaseURI . "/coursestatus";
             http_post_data($url, $data, true, $message);
             if ($message != "201") {
                 $data = User::encodeUser(User::createCourseStatus($userID, $courseID, $status));
                 $url = $databaseURI . "/coursestatus/course/{$courseID}/user/{$userID}";
                 http_put_data($url, $data, true, $message);
                 if ($message == "201") {
                     $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
                 } else {
                     $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetAdmin', $langTemplate));
                 }
             } else {
                 $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
             }
         }
     }
 }
 // creates a new user
 if ($_POST['action'] == "CreateUser") {