Example #1
0
 /**
  *	Concatenates the messages to flash the user in a string format.
  *	@return		String		The messages in the flash queue
  */
 public static function getFlash()
 {
     $session = Zend_Registry::getInstance()->get('session');
     $result = join(chr(10), (array) $session->flash);
     $session->flash = (array) null;
     return nl2br($result);
 }
Example #2
0
 /**
  * Initialize Doctrine
  * @return Doctrine_Manager
  */
 public function _initDoctrine()
 {
     // include and register Doctrine's class loader
     require_once 'Doctrine/Common/ClassLoader.php';
     $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPLICATION_PATH . '/../library/');
     $classLoader->register();
     // create the Doctrine configuration
     $config = new \Doctrine\ORM\Configuration();
     // setting the cache ( to ArrayCache. Take a look at
     // the Doctrine manual for different options ! )
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     // choosing the driver for our database schema
     // we'll use annotations
     $driver = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/models');
     $config->setMetadataDriverImpl($driver);
     // set the proxy dir and set some options
     $config->setProxyDir(APPLICATION_PATH . '/models/Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyNamespace('App\\Proxies');
     // now create the entity manager and use the connection
     // settings we defined in our application.ini
     $connectionSettings = $this->getOption('doctrine');
     $conn = array('driver' => $connectionSettings['conn']['driv'], 'user' => $connectionSettings['conn']['user'], 'password' => $connectionSettings['conn']['pass'], 'dbname' => $connectionSettings['conn']['dbname'], 'host' => $connectionSettings['conn']['host']);
     $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
     // push the entity manager into our registry for later use
     $registry = Zend_Registry::getInstance();
     $registry->entitymanager = $entityManager;
     return $entityManager;
 }
Example #3
0
 public function clearRegistry()
 {
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         $registry = Zend_Registry::getInstance();
         unset($registry['Zend_Translate']);
     }
 }
 public function getRemoteImageUrl()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     return $cdn['static']['url']['images'];
 }
Example #5
0
 public function indexAction()
 {
     $url = $this->getRequest()->getParam('url');
     $xmlString = '<?xml version="1.0" standalone="yes"?><response></response>';
     $xml = new SimpleXMLElement($xmlString);
     if (strlen($url) < 1) {
         $xml->addChild('status', 'failed no url passed');
     } else {
         $shortid = $this->db->fetchCol("select * from urls where url = ?", $url);
         $config = Zend_Registry::getInstance();
         $sh = $config->get('configuration');
         if ($shortid[0]) {
             $hex = dechex($shortid[0]);
             $short = $sh->siteroot . $hex;
         } else {
             //if not insert then return the id
             $data = array('url' => $url, 'createdate' => date("Y-m-d h:i:s"), 'remoteip' => Pandamp_Lib_Formater::getRealIpAddr());
             $insert = $this->db->insert('urls', $data);
             $id = $this->db->lastInsertId('urls', 'id');
             $hex = dechex($id);
             $short = $sh->siteroot . $hex;
         }
         $xml->addChild('holurl', $short);
         $xml->addChild('status', 'success');
     }
     $out = $xml->asXML();
     //This returns the XML xmlreponse should be key value pairs
     $this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($out);
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
 }
Example #6
0
 public function isValid($value)
 {
     $this->_setValue($value);
     $valueString = (string) $value;
     $people = Ml_Model_People::getInstance();
     if (mb_strstr($value, "@")) {
         $getUserByEmail = $people->getByEmail($value);
         if (empty($getUserByEmail)) {
             $this->_error(self::MSG_EMAIL_NOT_FOUND);
             return false;
         }
         Zend_Registry::getInstance()->set("loginUserInfo", $getUserByEmail);
         return true;
     }
     if (mb_strlen($value) == 0) {
         return false;
     }
     if (mb_strlen($value) > 20) {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     if (preg_match('#([^a-z0-9_-]+)#is', $value) || $value == '0') {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     $getUserByUsername = $people->getByUsername($value);
     if (empty($getUserByUsername)) {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     Zend_Registry::getInstance()->set("loginUserInfo", $getUserByUsername);
     return true;
 }
Example #7
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $registry = Zend_Registry::getInstance();
     $authedUserInfo = $registry->get('authedUserInfo');
     $uploadStatus = $registry->get("uploadStatus");
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $file = new Zend_Form_Element_File('file');
     $file->setLabel('Files:');
     $file->setRequired(true);
     $file->addValidator('Count', false, array('min' => 1, 'max' => 1));
     if ($uploadStatus['bandwidth']['remainingbytes'] > 0) {
         $maxFileSize = $uploadStatus['filesize']['maxbytes'];
     } else {
         $maxFileSize = 0;
     }
     $file->addValidator('Size', false, $maxFileSize);
     // hack for not showing 'the file exceeds the defined form size'
     $file->setMaxFileSize($maxFileSize * 2);
     /*$file->setMultiFile(1);*/
     $this->addElement($file, 'file');
     $title = $this->addElement('text', 'title', array('label' => 'Title:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 100)))));
     $short = $this->addElement('text', 'short', array('label' => 'Short description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 120)))));
     $description = $this->addElement('textarea', 'description', array('label' => 'Description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 4096)))));
 }
Example #8
0
 function __construct()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get('config');
     //		switch ($config->acl->config->db->adapter)
     //		{
     //			case subs
     //		}
     $host = $config->acl->config->db->param->host;
     $username = $config->acl->config->db->param->username;
     $password = $config->acl->config->db->param->password;
     $dbname = $config->acl->config->db->param->dbname;
     $gacl_options['debug'] = '';
     $gacl_options['db_type'] = 'mysql';
     $gacl_options['db_host'] = $host;
     $gacl_options['db_user'] = $username;
     $gacl_options['db_password'] = $password;
     $gacl_options['db_name'] = $dbname;
     $gacl_options['db_table_prefix'] = 'gacl_';
     $gacl_options['caching'] = '';
     $gacl_options['force_cache_expire'] = 1;
     $gacl_options['cache_dir'] = "/tmp/phpgacl_cache";
     $gacl_options['cache_expire_time'] = 600;
     $gacl_options['items_per_page'] = 100;
     $gacl_options['max_select_box_items'] = 100;
     $gacl_options['max_search_return_items'] = 200;
     $gacl_options['smarty_dir'] = "smarty/libs";
     $gacl_options['smarty_template_dir'] = "templates";
     $gacl_options['smarty_compile_dir'] = "templates_c";
     $this->_aclEngine = new Kutu_Acl_Vendor_PhpGaclApi($gacl_options);
     $this->_acl = new Kutu_Acl_Vendor_PhpGacl($gacl_options);
 }
Example #9
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $signedUserInfo = $registry->get('signedUserInfo');
     $uploadStatus = $registry->get("uploadStatus");
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $file = new Zend_Form_Element_File('file');
     $file->setRequired(false);
     $file->setLabel('What do you want to share today?');
     if ($uploadStatus['bandwidth']['remainingbytes'] > 0) {
         $maxFileSize = $uploadStatus['filesize']['maxbytes'];
     } else {
         $maxFileSize = 0;
     }
     $file->addValidator('Size', false, $maxFileSize);
     $file->setMaxFileSize($maxFileSize);
     $file->setMultiFile(4);
     $file->addValidator('Count', false, array('min' => 0, 'max' => 4));
     $this->addElement($file, 'file');
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'submitupload', array('label' => 'Upload!', 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
 function _initAcl()
 {
     $registry = Zend_Registry::getInstance();
     $acl = $registry->get('acl');
     $acl->addResource($this->_name . ':stores');
     $acl->addResource($this->_name . ':categories');
     $acl->addResource($this->_name . ':products');
     $acl->addResource($this->_name . ':carts');
     $acl->addResource($this->_name . ':accounts');
     /*
      * Divide role for users and guests on contoller stores
      */
     $acl->allow(Core_Role::ROLE_USER, $this->_name . ':stores', array('index', 'create', 'edit', 'delete', 'publish', 'unpublish'));
     /*
      * Divide role for users and guests on contoller categories
      */
     $acl->allow(Core_Role::ROLE_GUEST, $this->_name . ':categories', array());
     $acl->allow(Core_Role::ROLE_USER, $this->_name . ':categories', array('index', 'create', 'edit', 'delete'));
     /*
      * Divide role for users and guests on contoller products
      */
     $acl->allow(Core_Role::ROLE_GUEST, $this->_name . ':products', array());
     $acl->allow(Core_Role::ROLE_USER, $this->_name . ':products', array('index', 'create', 'edit', 'delete'));
     /*
      * Divide role for users and guests on contoller carts
      */
     $acl->allow(Core_Role::ROLE_GUEST, $this->_name . ':carts', array());
     $acl->allow(Core_Role::ROLE_USER, $this->_name . ':carts', array('index'));
     /*
      * Divide role for users and guests on contoller stores
      */
     $acl->allow(Core_Role::ROLE_GUEST, $this->_name . ':accounts', array());
     $acl->allow(Core_Role::ROLE_USER, $this->_name . ':accounts', array('index', 'edit'));
     $registry->set('acl', $acl);
 }
Example #11
0
 function preDispatch()
 {
     $this->_helper->layout()->setLayout('layout-final-inside');
     $saveHandlerManager = new Kutu_Session_SaveHandler_Manager();
     $saveHandlerManager->setSaveHandler();
     Zend_Session::start();
     $sReturn = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $sReturn = urlencode($sReturn);
     $this->view->returnTo = $sReturn;
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $this->_redirect(KUTU_ROOT_URL . '/helper/sso/login' . '?returnTo=' . $sReturn);
     } else {
         // [TODO] else: check if user has access to admin page
         $username = $auth->getIdentity()->username;
         $this->view->username = $username;
     }
     $userId = $auth->getIdentity()->guid;
     $tblUserFinance = new Kutu_Core_Orm_Table_UserFinance();
     $this->_userInfo = $tblUserFinance->find($userId)->current();
     //$config = new Zend_Config_Ini(CONFIG_PATH.'/store.ini', APPLICATION_ENV);
     $registry = Zend_Registry::getInstance();
     $reg = $registry->get(ZEND_APP_REG_ID);
     $storeConfig = $reg->getOption('store');
     $this->_configStore = $storeConfig;
 }
Example #12
0
 public function getDirPhotoUrl()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     return $cdn['static']['dir']['photo'];
 }
Example #13
0
 protected function getT()
 {
     if (!$this->translate) {
         $this->translate = Zend_Registry::getInstance()->translate;
     }
     return $this->translate;
 }
Example #14
0
 public function authAction()
 {
     $request = $this->getRequest();
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $DB = $registry['DB'];
     $authAdapter = new Zend_Auth_Adapter_DbTable($DB);
     $authAdapter->setTableName('fitness_admin_accounts')->setIdentityColumn('admin_username')->setCredentialColumn('admin_password');
     // Set the input credential values
     $uname = $request->getParam('user_username');
     $paswd = $request->getParam('user_password');
     $authAdapter->setIdentity($uname);
     $authAdapter->setCredential(md5($paswd));
     // Perform the authentication query, saving the result
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $data = $authAdapter->getResultRowObject(null, 'password');
         $auth->getStorage()->write($data);
         $sess = new Zend_Session_Namespace('AdminSession');
         if ($sess->isLocked()) {
             $sess->unlock();
         }
         $sess->username = $uname;
         $this->_redirect('/admin/homeuser');
     } else {
         $this->_redirect('/admin/index');
     }
 }
Example #15
0
    public function init() {
        $authNamespace = new Zend_Session_Namespace('Zend_Auth');
        $this->view->headLink()->appendStylesheet($this->view->BaseUrl() . '/themes/base/jquery.ui.all.css');
        $this->view->headLink()->appendStylesheet($this->view->BaseUrl() . '/css/dashboard.css');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/jquery.ui.core.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/jquery.ui.widget.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/jquery.ui.datepicker.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/i18n/jquery.ui.datepicker-es.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/jquery.validate.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/jquery.ui.mouse.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/ui/jquery.ui.draggable.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/jquery.number_format.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/highcharts.js');
        $this->view->headScript()->appendFile($this->view->BaseUrl() . '/js/dashboard.js');

        $this->me = Zend_Registry::get("me");
        if (!isset($this->me["id_usuario"])) {
            $data = new Application_Model_Usuario();
            $MP = new Application_Model_UsuarioMP();
            $MP->fetchByFb($this->me["id"], $data);
            $this->me["id_usuario"] = $data->getIdUsuario();
            $authNamespace->id_usuario = $this->me["id_usuario"];
        }
        Zend_Registry::getInstance()->set('me', $this->me);
        $request = $this->getRequest();
        $this->view->controlador = $request->getControllerName();
        $this->regMP = new Application_Model_RegistroMP();
        $this->proMP = new Application_Model_ProyectoMP();
        $pro = new Application_Model_Proyecto();
        $this->proMP->find($this->me['id_usuario'], $pro);
        $pro->setIngresos($this->regMP->fetchSumTipo(1, $pro->getIdProyecto()));
        $pro->setEgresos($this->regMP->fetchSumTipo(2, $pro->getIdProyecto()));
        $pro->setBalance($pro->getIngresos() - $pro->getEgresos());
        $this->view->proyecto = $pro;
    }
Example #16
0
 public static function setupConfiguration()
 {
     $config = new Zend_Config_Ini(self::$root . 'application/default/config/config.ini', 'desenvolvimento');
     self::$registry->configuration = $config;
     $session = Zend_Registry::getInstance();
     $session->set('config', $config);
 }
Example #17
0
 /**
  * Handles index request, which retrieves active log lines from all E3 instances and sources
  */
 public function indexAction()
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $logDepth = DEFAULT_LOG_DEPTH;
     $request = $this->getRequest();
     //$data = $request->getParams();
     //print_r($data);
     if ($request->isPost()) {
         $logDepth = is_array($_POST) && isset($_POST['log_depth']) ? $_POST['log_depth'] : DEFAULT_LOG_DEPTH;
         //print_r("Log depth: " . $log_depth);
     }
     $this->view->logDepth = $logDepth;
     $logCollection = $this->loggingManager->getAllActiveLogs($logDepth);
     if (!$logCollection) {
         //drupal_set_message("There was an error getting logs: " . $interface->error(), 'error');
         print_r($translate->translate("There was an error getting logs: ") . $this->loggingManager->error(), 'error');
         $this->view->logCollection = null;
     } else {
         $logs = array();
         foreach ($logCollection->logs as $log) {
             $logs[$log->ipAddress][$log->source] = $log->lines;
         }
         $this->view->logCollection = $logs;
     }
 }
Example #18
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $auth = Zend_Auth::getInstance();
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     if ($auth->hasIdentity()) {
         $this->addElement('password', 'currentpassword', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'matchPassword')), 'autocomplete' => 'off', 'required' => true, 'label' => 'Current Password:'******'class' => 'span3'));
     }
     $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'description' => "Six or more characters required; case-sensitive", 'validators' => array(array('validator' => 'StringLength', 'options' => array(6, 20)), array('validator' => 'Hardpassword'), array('validator' => 'newPassword'), array('validator' => 'newPasswordRepeat')), 'autocomplete' => 'off', 'required' => true, 'label' => 'New Password:'******'class' => 'span3'));
     $this->addElement('password', 'password_confirm', array('filters' => array('StringTrim'), 'required' => true, 'label' => 'Confirm Password:'******'autocomplete' => 'off', 'class' => 'span3'));
     if ($registry->isRegistered("changeUserProperPassword")) {
         $this->addElement(Ml_Model_AntiAttack::captchaElement());
     }
     $this->addElement('submit', 'submit', array('label' => 'Change it!', 'class' => 'btn primary'));
     if ($config['ssl']) {
         $this->getElement("submit")->addValidator("Https");
         //By default the submit element doesn't display a error decorator
         $this->getElement("submit")->addDecorator("Errors");
     }
     if ($auth->hasIdentity()) {
         $this->addElement(Ml_Model_MagicCookies::formElement());
     }
     $this->setAttrib('class', 'form-stacked');
 }
Example #19
0
 public function __construct()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     self::$_prePath = mb_substr($config['cdn'], 0, -1);
     self::$_cacheFiles = $this->loadVersions();
 }
 public function getLatLng($address)
 {
     # address identifier
     $address_identifier = 'latlng_' . str_replace(array(' '), array('_'), $address);
     $address_identifier = preg_replace('/[^a-z0-9_]+/i', '', $address);
     # registry
     $registry = Zend_Registry::getInstance();
     # caching
     $frontendOptions = array('lifetime' => 2592000, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $registry->config->application->logs->tmpDir . '/cache/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     # get data
     if (($data = $cache->load($address_identifier)) === false) {
         new Custom_Logging('Hit Google: Lat/Lng for ' . $address, Zend_Log::INFO);
         $client = new Zend_Http_Client('http://maps.google.com/maps/geo?q=' . urlencode($address), array('maxredirects' => 0, 'timeout' => 30));
         $request = $client->request();
         $response = Zend_Http_Response::fromString($request);
         $body = Zend_Json::decode($response->getBody());
         $data = array();
         $data['latitude'] = !empty($body['Placemark'][0]['Point']['coordinates'][1]) ? $body['Placemark'][0]['Point']['coordinates'][1] : null;
         $data['longitude'] = !empty($body['Placemark'][0]['Point']['coordinates'][0]) ? $body['Placemark'][0]['Point']['coordinates'][0] : null;
         $cache->save($data, $address_identifier);
     } else {
         new Custom_Logging('(local cache) Hit Google: Lat/Lng for ' . $address, Zend_Log::INFO);
     }
     return $data;
 }
Example #21
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $result = $auth->getStorage();
     $identity = $auth->getIdentity();
     $registry = Zend_Registry::getInstance();
     $config = Zend_Registry::get('config');
     $module = strtolower($this->_request->getModuleName());
     $controller = strtolower($this->_request->getControllerName());
     $action = strtolower($this->_request->getActionName());
     if ($identity && $identity != "") {
         $layout = Zend_Layout::getMvcInstance();
         $view = $layout->getView();
         $view->login = $identity;
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $id = $siteInfoNamespace->userId;
         $view->firstname = $siteInfoNamespace->Firstname;
         $username = $siteInfoNamespace->username;
         $password = $siteInfoNamespace->password;
         $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $config->resources->db->params->host, 'username' => $username, 'password' => $password, 'dbname' => $config->resources->db->params->dbname));
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
         return;
     } else {
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $siteInfoNamespace->requestURL = $this->_request->getParams();
         $this->_request->setModuleName('default');
         $this->_request->setControllerName('Auth');
         $this->_request->setActionName('login');
     }
 }
Example #22
0
 protected function _initMessages()
 {
     // save to registry
     $registry = Zend_Registry::getInstance();
     $registry->set('files', $_FILES);
     unset($config);
 }
 /**
  * reload the DB tables using the DB SQL dump found in config/zfdemo.<type>.sql 
  */
 public function resetAction()
 {
     // STAGE 3: Choose, create, and optionally update models using business logic.
     $registry = Zend_Registry::getInstance();
     $db = $registry['db'];
     // if the DB is not configured to handle "large" queries, then we need to feed it bite-size queries
     $filename = $registry['configDir'] . 'zfdemo.' . $registry['config']->db->type . '.sql';
     $statements = preg_split('/;\\n/', file_get_contents($filename, false));
     foreach ($statements as $blocks) {
         $sql = '';
         foreach (explode("\n", $blocks) as $line) {
             if (empty($line) || !strncmp($line, '--', 2)) {
                 continue;
             }
             $sql .= $line . "\n";
         }
         $sql = trim($sql);
         if (!empty($sql)) {
             $db->query($sql);
         }
     }
     // STAGE 4: Apply business logic to create a presentation model for the view.
     $this->view->filename = $filename;
     // STAGE 5: Choose view and submit presentation model to view.
     $this->renderToSegment('body');
 }
Example #24
0
/**
 *
 * @param mixed $var
 * @param mixed $default
 * @return string
 */
function smarty_modifier_isAllowed($resource)
{
    $acl = Zend_Registry::getInstance()->get('container')->get('manager_acl')->getAcl();
    $userSession = Zend_Registry::getInstance()->get('container')->get('user_session');
    $role = $userSession->getAccessRole()->getIdAccessRole();
    return $acl->isAllowed($role, $resource);
}
Example #25
0
 public function viewconfigAction()
 {
     $config = Zend_Registry::getInstance()->configuration->formatter;
     $fmt_path = APPLICATION_PATH . "/" . $config->dir . "/";
     $filesf = scandir($fmt_path);
     $allconfig = array();
     foreach ($filesf as $file) {
         $path = realpath($fmt_path . $file);
         if (is_dir($path) && is_file($path . "/config.ini")) {
             $carr = parse_ini_file($path . "/config.ini", true) or $carr = array();
             $allconfig[$file] = $carr;
         }
     }
     $this->view->allconfig = $allconfig;
     $this->view->setData = array();
     $this->view->setTitle = "";
     $request = $this->getRequest()->getQuery();
     if (isset($request['set'])) {
         $this->view->setTitle = @$request['set'];
     }
     // get user settings
     $conn = $this->getDB();
     $dbsettings = array();
     $recordSet = $conn->Execute("SELECT * FROM `viewconfig` ORDER BY `name`,`fmt`;");
     while (!$recordSet->EOF) {
         $raw_data = $recordSet->GetRowAssoc(false);
         $dbsettings[$raw_data['name']][$raw_data['fmt']][$raw_data['key']] = $raw_data['value'];
         if ($this->view->setTitle == $raw_data['name']) {
             $this->view->setData[$raw_data['fmt']][$raw_data['key']] = $raw_data['value'];
         }
         $recordSet->MoveNext();
     }
     $this->view->allsets = $dbsettings;
 }
Example #26
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $sysCache = $registry->get("sysCache");
     $cacheFiles = new Ml_Cache_Files($sysCache);
     Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers');
     $frontController = $this->getBootstrap()->getResource('FrontController');
     $dispatcher = $frontController->getDispatcher();
     $request = $frontController->getRequest();
     $router = $frontController->getRouter();
     $router->removeDefaultRoutes();
     $compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
     $router->addRoute(HOST_MODULE, $compat);
     $routerConfig = $cacheFiles->getConfigIni(APPLICATION_PATH . '/configs/' . HOST_MODULE . 'Routes.ini');
     $router->addConfig($routerConfig, "apiroutes");
     Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers/helpers');
     $loadOauthStore = Zend_Controller_Action_HelperBroker::getStaticHelper("LoadOauthstore");
     $loadOauthStore->setinstance();
     $loadOauthStore->preloadServer();
     $frontController->setBaseUrl($config['apiroot'])->setParam('noViewRenderer', true)->addModuleDirectory(APPLICATION_PATH . '/modules')->addControllerDirectory(APPLICATION_PATH . '/modules/' . HOST_MODULE . '/controllers');
     $response = new Zend_Controller_Response_Http();
     if (filter_input(INPUT_GET, "responseformat", FILTER_UNSAFE_RAW) == 'json') {
         $contentType = 'application/json';
     } else {
         $contentType = 'text/xml';
     }
     $response->setHeader('Content-Type', $contentType . '; charset=utf-8', true);
     $frontController->setResponse($response);
 }
Example #27
0
 public function pseudoshareSetUp()
 {
     $registry = Zend_Registry::getInstance();
     $request = $this->getRequest();
     if ($request->getUserParam('username') && !$registry->isRegistered("userInfo")) {
         //avoid calling the DB again for nothing
         if (isset($registry['signedUserInfo']) && $registry['signedUserInfo']['alias'] == $request->getUserParam('username')) {
             $userInfo = $registry['signedUserInfo'];
         } else {
             $people = Ml_Model_People::getInstance();
             $userInfo = $people->getByUsername($request->getUserParam('username'));
         }
         if (!$userInfo) {
             $registry->set("notfound", true);
             throw new Exception("User does not exists.");
         }
         $registry->set("userInfo", $userInfo);
         $registry->set("requestUserParams", $this->getRequest()->getUserParams());
         if ($this->getRequest()->getUserParam("share_id")) {
             $share = Ml_Model_Share::getInstance();
             $shareInfo = $share->getById($this->getRequest()->getUserParam("share_id"));
             if (!$shareInfo) {
                 $registry->set("notfound", true);
                 throw new Exception("Share does not exists.");
             } else {
                 if ($shareInfo['byUid'] != $userInfo['id']) {
                     $registry->set("notfound", true);
                     throw new Exception("Share owned by another user.");
                 }
             }
             $registry->set("shareInfo", $shareInfo);
         }
     }
 }
Example #28
0
 public function indexAction()
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/manager.ini', null, true);
     $validationErrors = array();
     if ($this->getRequest()->isPost()) {
         $c = $this->_getParam('config');
         if (empty($c['manager_host'])) {
             $validationErrors['manager_host'] = $translate->translate("Manager host is required");
         }
         if (empty($c['gateway_host'])) {
             $validationErrors['gateway_host'] = $translate->translate("Gateway host is required");
         }
         if (empty($validationErrors)) {
             $config->manager_host = $c['manager_host'];
             $config->gateway_host = $c['gateway_host'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => APPLICATION_PATH . '/configs/manager.ini'));
             $writer->write();
             $this->view->flashMessage = $translate->translate("Preferences Updated");
         }
     }
     $this->view->config = $config;
     $this->view->validationErrors = $validationErrors;
 }
Example #29
0
/**
 * Hook for SECTION: i18n (translation)
 */
function _($msg)
{
    /////////////////////////////
    // ==> SECTION: i18n <==
    // Need volunteers to help create translations for the catalog in data/zfdemo.mo
    // Nice tool to help manage the gettext catalog: http://www.poedit.net/
    static $translator = null;
    if ($translator === null) {
        require_once 'Zend/Translate.php';
        $registry = Zend_Registry::getInstance();
        $translator = new Zend_Translate('gettext', $registry['dataDir'] . 'zfdemo.mo', $registry['userLocale']);
    }
    if (func_num_args() === 1) {
        return $translator->_($msg);
    } else {
        $args = func_get_args();
        array_shift($args);
        return vsprintf($translator->_($msg), $args);
    }
    /////////////////////////////
    // ==> SECTION: mvc <==
    if (func_num_args() === 1) {
        return $msg;
    } else {
        $args = func_get_args();
        array_shift($args);
        return vsprintf($msg, $args);
    }
}
Example #30
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     //starten des Zend_Layouts
     $layout = Zend_Layout::startMvc(array('layoutPath' => '../application/modules/default/views/layouts'));
     $contollerName = $request->getControllerName();
     $modulName = $request->getModuleName();
     if ($contollerName == 'make' and $modulName == 'annotation' or $contollerName == 'browse' and $modulName == 'annotation' and $request->getActionName() != 'index') {
         $layout->disableLayout();
         //setLayout('flexlayout');
     } elseif ($modulName == 'service') {
         $layout->disableLayout();
     } elseif ($modulName == 'image' and $contollerName == 'index') {
         $layout->disableLayout();
     } else {
         $layout->setLayout('layout');
     }
     // der view Voreinstellungen übergeben
     $view = $layout->getView();
     $view->doctype('XHTML1_TRANSITIONAL');
     $view->headLink(array('href' => '/styles/index.css', 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen'));
     $view->headLink(array('href' => '/images/website/favicon.ico', 'rel' => 'shortcut icon'));
     $view->headTitle(Zend_Registry::get('APP_NAME'));
     //??$view->headMeta()->appendName('http-equiv','text/html; charset=utf-8');
     // register the MESSAGE key
     $registry = Zend_Registry::getInstance();
     $registry->MESSAGE = '';
 }