/** * cancel an action in category manager (Cancel). * */ function Joom_CancelCategory() { $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $row = new mosCatgs($database); $row->bind($_POST); $row->checkin(); // redirect to category manager $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=categories'); }
/** * Aendern einer bestehenden Kategorie */ function Joom_User_EditPic() { $config = Joom_getConfig(); $mainframe =& JFactory::getApplication('site'); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); $row = new mosjoomgallery($database); $row->load($this->picid); if ($row->owner != $user->get('id') && !$this->adminlogged) { $mainframe->redirect(JRoute::_('index.php?option=com_joomgallery' . _JOOM_ITEMID, false), JText::_('JGS_ALERT_NOT_ALLOWED_TO_EDIT_PICTURE')); } if ($this->adminlogged) { $clist = Joom_ShowDropDownCategoryList($row->catid, 'catid'); } else { $clist = $this->Joom_User_ShowDropDownCategoryList($row->catid); } //wenn $clist = null, wurde das Bild in eine Backend-Kategorie geladen, //die nicht mehr freigeschaltet ist. Oder es handelt sich um die einzige //Kategorie. In diesem Fall nur den Text der Kategorie ausgeben if ($clist == null) { $rowcat = new mosCatgs($database); $rowcat->load($row->catid); $clist = $rowcat->name; } HTML_Joom_UserPanel::Joom_User_EditPic_HTML($row, $clist); }
/** * creates a new category out of the information of the given object * * @param object should hold all the information about the new category * @return int/boolean id of the created category on success, false otherwise */ function createCategory($obj) { $database =& JFactory::getDBO(); jimport('joomla.filesystem.file'); /*JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_joomgallery'.DS.'tables'); $row = & JTable::getInstance('joomgallerycategories', 'Table');*/ /* deprecated (use JTable instead as shown above): */ require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomgallery' . DS . 'joomgallery.class.php'; $row = new mosCatgs($database); $row->bind($obj); //store data in the database if (!$row->store()) { return false; } //now we have the id of the new category //and the catpath can be built $row->catpath = Joom_FixFilename($row->name) . '_' . $row->cid; if ($row->parent) { $row->catpath = Joom_GetCatPath($row->parent) . $row->catpath; } //so store again if (!$row->store()) { return false; } //create necessary folders and files $origpath = JPATH_ROOT . DS . $this->_jg_config->jg_pathoriginalimages . $row->catpath; $imgpath = JPATH_ROOT . DS . $this->_jg_config->jg_pathimages . $row->catpath; $thumbpath = JPATH_ROOT . DS . $this->_jg_config->jg_paththumbs . $row->catpath; $index = JPATH_SITE . DS . 'components' . DS . 'com_joomgallery' . DS . 'assets' . DS . 'index.html'; $result = array(); $result[] = JFolder::create($origpath); $result[] = JFile::copy($index, $origpath . DS . 'index.html'); $result[] = JFolder::create($imgpath); $result[] = JFile::copy($index, $imgpath . DS . 'index.html'); $result[] = JFolder::create($thumbpath); $result[] = JFile::copy($index, $thumbpath . DS . 'index.html'); if (in_array(false, $result)) { return false; } else { return $row->cid; } }
/** * Update of category path in DB for subcategories if a parent category has * been moved or the name changed * recursive call to each count of depth * * @param integer $catids_values: ID(s) of the modifie category * @param string $oldpath: former rel. category path * @param string $newpath: actual rel. category path * */ function Joom_UpdateNewCatpath($catids_values, &$oldpath, &$newpath) { $database =& JFactory::getDBO(); //query for subcategories with parent in $catids_values $database->setQuery("SELECT cid\n FROM #__joomgallery_catg\n WHERE parent in ({$catids_values}) "); $subcatids = $database->loadResultArray(); if ($database->getErrorNum()) { echo $database->stderr(true); } // nothing found, return if (count($subcatids) == 0) { return; } $row = new mosCatgs($database); foreach ($subcatids as $subcatid) { $row->load($subcatid); $catpath = $row->catpath; //replace former category path with actual one $catpath = str_replace($oldpath . '/', $newpath . '/', $catpath); //and save it $row->catpath = $catpath; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } } //split the array in comme seperated string $catids_values = implode(",", $subcatids); //call again with subcategories as parent Joom_UpdateNewCatpath($catids_values, $oldpath, $newpath); }
/** * Move pictures * @param array $id: id's of pictures to be moved */ function Joom_SaveMovePicture($id) { $config = Joom_getConfig(); $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); jimport('joomla.filesystem.file'); //TODO: error messages //id of destination category $pictureMove = JRequest::getInt('catid', '', 'post'); //when no category chosen before if (!$pictureMove || $pictureMove == 0) { //error message and abort echo "<script> alert('" . JText::_('JGA_ALERT_PLEASE_SELECT_CATEGORY', true) . "');\n window.history.go(-1);</script>\n"; exit; //category chosen } else { //and the array contains picture if (count($id)) { //create a new array which contains the succesful moved pictures $successids = array(); //loop through array for ($i = 0; $i < count($id); $i++) { //database query for picture title and the catid from source category $database->setQuery("SELECT id, catid, imgfilename, imgthumbname\n FROM #__joomgallery\n WHERE id = {$id[$i]}"); //if succesful if ($database->query()) { //write in array $rows = $database->loadObjectList(); $row = $rows[0]; //write to class members $this->imgfilename = $row->imgfilename; $this->imgthumbname = $row->imgthumbname; $old_catid = $row->catid; //catpath for new category $catpath = Joom_GetCatPath($pictureMove); //catpath for old category $catpath_ori = Joom_GetCatPath($row->catid); //query if there are entries in which the picture file to move //is assigned and count them $database->setQuery("SELECT COUNT(id)\n FROM #__joomgallery\n WHERE imgthumbname = '" . $this->imgthumbname . "'\n AND id != '" . $id[$i] . "'\n AND catid = '" . $old_catid . "'"); $count2 = $database->loadResult(); //check if thumbnail already exists in source directory and not //exists already in destination //otherwise the file will not be copied if (JFile::exists(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath_ori . $this->imgthumbname) && !JFile::exists(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $this->imgthumbname)) { //if there is no picture remaining in source directory //which uses the picture if ($count2 < 1) { //move the thumbnail $result = JFile::move($config->jg_paththumbs . $catpath_ori . $this->imgthumbname, $config->jg_paththumbs . $catpath . $this->imgthumbname, JPATH_ROOT); //otherwise... } else { //copy the thumbnail and let it remain in source $result = JFile::copy($config->jg_paththumbs . $catpath_ori . $this->imgthumbname, $config->jg_paththumbs . $catpath . $this->imgthumbname, JPATH_ROOT); } //if not succesful error message and abort if (!$result) { Joom_AlertErrorMessages(0, 0, 0, $successids); } //set control variable according to succesful move/copy $thumb = 1; //not succesful } else { $thumb = 0; } //same procedure with detail //in case of error call previous copy/move of $database->setQuery("SELECT COUNT(id)\n FROM #__joomgallery\n WHERE imgfilename = '" . $this->imgfilename . "'\n AND id != '" . $id[$i] . "'\n AND catid = '" . $old_catid . "'"); $count = $database->loadResult(); $imgsource = JPATH_ROOT . DS . $config->jg_pathimages . $catpath_ori . $this->imgfilename; $imgdest = JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $this->imgfilename; if (JFile::exists($imgsource) && !JFile::exists($imgdest)) { if ($count < 1) { $result2 = JFile::move($catpath_ori . $this->imgfilename, $catpath . $this->imgfilename, JPATH_ROOT . DS . $config->jg_pathimages); } else { $result2 = JFile::copy($catpath_ori . $this->imgfilename, $catpath . $this->imgfilename, JPATH_ROOT . DS . $config->jg_pathimages); } if (!$result2) { if ($thumb == 1) { if ($count2 < 1) { JFile::move($config->jg_paththumbs . $catpath . $this->imgthumbname, $config->jg_paththumbs . $catpath_ori . $this->imgthumbname, JPATH_ROOT); } else { JFile::delete(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $this->imgthumbname); } } Joom_AlertErrorMessages(0, 0, 0, $successids); } $picture = 1; } else { $picture = 0; } if (JFile::exists(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath_ori . $this->imgfilename) && !JFile::exists(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $this->imgfilename)) { if ($count < 1) { $result3 = JFile::move($catpath_ori . $this->imgfilename, $catpath . $this->imgfilename, JPATH_ROOT . DS . $config->jg_pathoriginalimages); } else { $result3 = JFile::copy($catpath_ori . $this->imgfilename, $catpath . $this->imgfilename, JPATH_ROOT . DS . $config->jg_pathoriginalimages); } if (!$result3) { if ($thumb == 1) { if ($count2 < 1) { JFile::move($config->jg_paththumbs . $catpath . $this->imgthumbname, $config->jg_paththumbs . $catpath_ori . $this->imgthumbname, JPATH_ROOT); } else { JFile::delete(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $this->imgthumbname); } } if ($picture == 1) { if ($count < 1) { JFile::move($config->jg_pathimages . $catpath . $this->imgfilename, $config->jg_pathimages . $catpath_ori . $this->imgfilename, JPATH_ROOT); } else { JFile::delete(JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $this->imgfilename); } } Joom_AlertErrorMessages(0, 0, 0, $successids); } } //if database query not succesful error message and abort } else { echo "<script> alert('" . $database->getErrorMsg() . "');\n window.history.go(-1); </script>\n"; } //add the succesful processed picture (id) to array array_push($successids, $id[$i]); //if all folder operations for the picture succesful //modify the database entry $pic = new mosjoomgallery($database); //call Joom_MovePictures $pic->Joom_MovePictures($id[$i], $pictureMove); //new object from mosCatgs $cat = new mosCatgs($database); $cat->load($pictureMove); } } //construct the success message //count of moved pictures $total = count($successids); //TODO: MSG 'x Bilder verschoben zu y' anpassen $msg = $total . " Pictures moved to " . $cat->name; //redirect to picture manager with success message $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=pictures', $msg); } }