Exemplo n.º 1
0
 public function shareSet()
 {
     $pn_set_id = $this->request->getParameter('set_id', pInteger);
     $t_set = new ca_sets();
     if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__, $pn_set_id)) {
         $this->notification->addNotification(_t("You cannot share this set"), "message");
     } else {
         $t_set->load($pn_set_id);
         $vs_form_prefix = 'shareSetForm_';
         $va_users_to_set = array();
         foreach ($_REQUEST as $vs_key => $vs_val) {
             if (preg_match("!^{$vs_form_prefix}id(.*)\$!", $vs_key, $va_matches)) {
                 $vn_user_id = (int) $this->request->getParameter($vs_form_prefix . 'id' . $va_matches[1], pInteger);
                 $vn_access = $this->request->getParameter($vs_form_prefix . 'access_' . $va_matches[1], pInteger);
                 if ($vn_access > 0) {
                     $va_users_to_set[$vn_user_id] = $vn_access;
                 }
             }
         }
         $t_set->setUsers($va_users_to_set);
         if ($t_set->numErrors()) {
             $this->notification->addNotification(_t("There were errors while sharing: %1", join("; ", $t_set->getErrors())), "message");
         } else {
             $vn_c = sizeof($va_users_to_set);
             $this->notification->addNotification($vn_c == 1 ? _t("Shared set with %1 user", $vn_c) : _t("Shared set with %1 users", $vn_c), "message");
         }
     }
     $this->index();
 }