public function getAction() { $id = (int) $this->_getParam('id'); $record = $this->newModelObject(); if (!empty($id)) { $record = $record->find($id); Phprojekt::setCurrentProjectId($record->projectId); } Phprojekt_CompressedSender::send(Zend_Json_Encoder::encode(Phprojekt_Model_Converter::convertModel($record))); }
/** * Sets a fields definitions for each field. * * @return void */ public function setFields() { // password $this->fillField('password', 'Password', 'password', 0, 1, array('length' => 50)); // confirmValue $this->fillField('confirmValue', 'Confirm Password', 'password', 0, 2, array('length' => 50)); // oldValue $this->fillField('oldValue', 'Old Password', 'password', 0, 3, array('length' => 50)); // email $this->fillField('email', 'Email', 'text', 0, 4, array('length' => 255)); // language $range = array(); foreach ($this->_languageRange as $key => $value) { $range[] = $this->getRangeValues($key, $value); } $this->fillField('language', 'Language', 'selectbox', 0, 5, array('range' => $range, 'required' => true, 'default' => 'en')); // timeZone $range = array(); foreach ($this->_timeZoneRange as $key => $value) { $range[] = $this->getRangeValues($key, $value); } $this->fillField('timeZone', 'Time zone', 'selectbox', 0, 6, array('range' => $range, 'required' => true, 'default' => '000')); // Proxies Phprojekt::setCurrentProjectId(IndexController::INVISIBLE_ROOT); $user = new Phprojekt_User_User(); $range = $user->getAllowedUsers(); // remove ourselves from the proxy list $i = 0; foreach ($range as $entry) { if ((int) $entry['id'] == Phprojekt_Auth::getUserId()) { array_splice($range, $i, 1); break; } $i++; } $this->fillField('proxies', 'Proxies', 'multiplefilteringselectbox', 0, 7, array('range' => $range, 'required' => true)); }
/** * Keep in the session the current project ID. * * @return void */ public function setCurrentProjectId() { Phprojekt::setCurrentProjectId(self::INVISIBLE_ROOT); }
/** * Keep in the registry the current project id. * * @return void */ public function setCurrentProjectId() { $projectId = (int) $this->getRequest()->getParam("nodeId"); if (empty($projectId)) { throw new Phprojekt_PublishedException(self::NODEID_REQUIRED_TEXT); } else { Phprojekt::setCurrentProjectId($projectId); } }
/** * Deletes a certain item. * * REQUIRES request parameters: * <pre> * - integer <b>id</b> id of the item to delete. * </pre> * * The return is a string in JSON format with: * <pre> * - type => 'success' or 'error'. * - message => Success or error message. * - id => id of the deleted item. * </pre> * * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete. * * @return void */ public function jsonDeleteAction() { $id = (int) $this->getRequest()->getParam('id'); if (empty($id)) { throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400); } $model = $this->getModelObject()->find($id); if (empty($model)) { throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404); } if ($model->hasField('projectId')) { Phprojekt::setCurrentProjectId($model->projectId); } if ($model instanceof Phprojekt_ActiveRecord_Abstract) { $tmp = Default_Helpers_Delete::delete($model); if ($tmp === false) { $message = Phprojekt::getInstance()->translate(self::DELETE_FALSE_TEXT); $resultType = 'error'; } else { $message = Phprojekt::getInstance()->translate(self::DELETE_TRUE_TEXT); $resultType = 'success'; } $return = array('type' => $resultType, 'message' => $message, 'id' => $id); Phprojekt_Converter_Json::echoConvert($return); } else { throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404); } }