Пример #1
0
 /**
  * Delete users
  *
  * @param   int	user ID
  * @param   int	SKU ID
  * @return  void
  */
 public static function addSkuUser($uId, $sId)
 {
     return RestrictionsHelper::addUser('sku', $uId, $sId);
 }
Пример #2
0
 public function uploadcsvTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // See if we have a file
     $csvFile = Request::getVar('csvFile', false, 'files', 'array');
     $sId = Request::getVar('sId', '');
     if (isset($csvFile['name']) && $csvFile['name'] && $csvFile['type'] == 'text/csv') {
         if (($handle = fopen($csvFile['tmp_name'], "r")) !== FALSE) {
             $inserted = 0;
             $skipped = array();
             $ignored = array();
             while (($line = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if (!empty($line[0])) {
                     $usr = new \Hubzero\User\Profile(trim($line[0]));
                     $uId = $usr->get('uidNumber');
                     if ($uId) {
                         $res = RestrictionsHelper::addSkuUser($uId, $sId);
                         if ($res) {
                             $inserted++;
                         } else {
                             $skipped[] = $usr;
                         }
                     } else {
                         $ignored[] = $line[0];
                     }
                 }
             }
             fclose($handle);
         } else {
             $this->view->setError('Could not read the file.');
         }
     } else {
         $this->view->setError('No file or bad file was uploaded. Please make sure you upload the CSV formated file.');
     }
     // Output the HTML
     $this->view->sId = $sId;
     $this->view->inserted = $inserted;
     $this->view->skipped = $skipped;
     $this->view->ignored = $ignored;
     $this->view->display();
 }