/**
  *
  */
 private function _getFolderID($pn_folder_id = null, $pn_user_id = null)
 {
     global $AUTH_CURRENT_USER_ID;
     if (!$pn_user_id) {
         $pn_user_id = $AUTH_CURRENT_USER_ID;
     }
     $vn_folder_id = $this->getPrimaryKey();
     if ($pn_folder_id && $vn_folder_id != $pn_folder_id) {
         $t_folder = new ca_bookmark_folders($pn_folder_id);
         if ($t_folder->get('user_id') == $pn_user_id) {
             return $t_folder->getPrimaryKey();
         }
         return false;
     }
     if ($this->get('user_id') == $pn_user_id) {
         return $this->getPrimaryKey();
     }
     return false;
 }
Exemplo n.º 2
0
 public function addNewFolder()
 {
     if (!$this->request->isLoggedIn()) {
         $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
         return;
     }
     global $g_ui_locale_id;
     // current locale_id for user
     $va_errors_new_folder = array();
     $o_purifier = new HTMLPurifier();
     $t_new_folder = new ca_bookmark_folders();
     $pn_folder_id = $this->request->getParameter('folder_id', pInteger);
     $ps_name = $o_purifier->purify($this->request->getParameter('name', pString));
     if (!$ps_name) {
         $va_errors_new_folder["name"] = _t("Please enter the name of your folder");
     }
     if (sizeof($va_errors_new_folder) == 0) {
         $t_new_folder->setMode(ACCESS_WRITE);
         $t_new_folder->set('user_id', $this->request->getUserID());
         $t_new_folder->set('name', $ps_name);
         $t_new_folder->insert();
         if ($vn_new_folder_id = $t_new_folder->getPrimaryKey()) {
             // select the current folder
             $this->request->user->setVar('current_folder_id', $vn_new_folder_id);
             //clear t_new_folder object so form appears blank and load t_folder so edit form is populated
             $t_new_folder = new ca_bookmark_folders();
             $t_folder = new ca_bookmark_folders($vn_new_folder_id);
         }
     }
     $this->view->setVar('errors_new_folder', $va_errors_new_folder);
     $this->index();
 }