/** * Returns the folder by the photo id * @param int $photoId The identifier of the photo * @return null|object */ public function getFolderByPhotoId($photoId) { if (!($photo = $this->getById($photoId))) { return null; } if (!class_exists($classname = 'GridGallery_Photos_Model_Folders', false)) { if ($this->debugEnabled) { wp_die(sprintf('The required class \'%s\' is does not exists', $classname)); } return null; } $folders = new GridGallery_Photos_Model_Folders($this->debugEnabled); return $folders->getById($photo->folder_id); }
/** * Update Title Action * Updates the title of the folder * * @param Rsc_Http_Request $request * @return Rsc_Http_Response */ public function updateTitleAction(Rsc_Http_Request $request) { $env = $this->getEnvironment(); $folders = new GridGallery_Photos_Model_Folders(); $title = trim($request->post->get('folder_name')); $folderId = $request->post->get('folder_id'); if (empty($title)) { return $this->response('ajax', array('error' => true, 'message' => $env->translate('The title can\'t be empty'))); } if ($folders->updateTitle($folderId, $title)) { return $this->response('ajax', array('error' => false, 'message' => $env->translate('Title successfully updated'))); } return $this->response('ajax', array('error' => true, 'message' => $env->translate('Unable to update the title. Try again later'))); }