function smarty_function_loadExtension($params, &$smarty)
{
    //fetch plugin name
    $extName = $params['name'];
    $config =& $params['config'];
    if (empty($extName)) {
        return "No Extension selected";
    }
    $extParams = array();
    if (isset($params['params'])) {
        //Explode Params
        $tmpParams = explode(",", $params['params']);
        foreach ($tmpParams as $val) {
            $para = explode("=", $val);
            $extParams[trim($para[0])] = trim($para[1]);
        }
    }
    // now we got the name and the params so lets include and pass
    require_once $config->miplexDir . "ExtensionManager.class.php";
    $extManager = new ExtensionManager($config);
    $ext = $extManager->loadExtension($extName);
    if ($ext != false) {
        return $ext->main($extParams);
    } else {
        return "Plugin not Found";
    }
}
 /**
  * Evaluate Extension by getting the name and the params
  * ###mailform(param=value, param=value)###
  *
  * @param String $string The content to parse
  */
 function evaluateExtension($string)
 {
     $regex = "/###Ext:(.*)###/";
     $regex2 = "/^(.*)\\((.*)\\)\$/";
     preg_match($regex, $string, $matches);
     if (!empty($matches[1])) {
         preg_match($regex2, $matches[1], $params);
         if (!empty($params[1])) {
             $extName = $params[1];
             $tmpParams = $params[2];
             //Explode Params
             $tmpParams = explode(",", $tmpParams);
             foreach ($tmpParams as $val) {
                 $para = explode("=", $val);
                 $extParams[trim($para[0])] = trim($para[1]);
             }
             //now we got the name and the params so lets include and pass
             require_once $this->config->miplexDir . "ExtensionManager.class.php";
             $extManager = new ExtensionManager($this->config);
             $ext = $extManager->loadExtension($extName);
             if ($ext != false) {
                 $ret = $ext->main($extParams);
                 $this->ext = 1;
             } else {
                 $ret = "Plugin not Found";
             }
             $string = preg_replace($regex, $ret, $string);
         }
     }
     return $string;
 }
 /**
  * Update function
  */
 public function update()
 {
     // Support for the multilanguage extension by Giel Berkers:
     // http://github.com/kanduvisla/multilanguage
     //
     // See if the multilingual extension is installed:
     require_once TOOLKIT . '/class.extensionmanager.php';
     $extensionManager = new ExtensionManager($this);
     $status = $extensionManager->fetchStatus('multilanguage');
     if ($status == EXTENSION_ENABLED) {
         // Append some extra rows to the search-index table:
         $languages = explode(',', file_get_contents(MANIFEST . '/multilanguage-languages'));
         // Check which fields exist:
         $columns = Symphony::Database()->fetch("SHOW COLUMNS FROM `tbl_search_index`");
         $fields = array();
         foreach ($columns as $column) {
             $fields[] = $column['Field'];
         }
         foreach ($languages as $language) {
             $field = 'data_' . $language;
             if (!in_array($field, $fields)) {
                 Administration::instance()->Database->query("ALTER TABLE `tbl_search_index` ADD `" . $field . "` TEXT, ADD FULLTEXT (`" . $field . "`)");
             }
         }
     }
     // End Support
 }
 function listAll()
 {
     $result = array();
     $people = array();
     $structure = General::listStructure(TEXTFORMATTERS, '/formatter.[\\w-]+.php/', false, 'ASC', TEXTFORMATTERS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = str_replace(array('formatter.', '.php'), '', $f);
             $result[$f] = $this->about($f);
         }
     }
     $extensionManager = new ExtensionManager($this->_Parent);
     $extensions = $extensionManager->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/text-formatters")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/text-formatters", '/formatter.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/text-formatters");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = preg_replace(array('/^formatter./i', '/.php$/i'), '', $f);
                     $result[$f] = $this->about($f);
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 function __construct(&$parent)
 {
     parent::__construct($parent);
     $this->setTitle('Symphony – Member Roles');
     $ExtensionManager = new ExtensionManager($parent);
     $this->_driver = $ExtensionManager->create('members');
 }
Ejemplo n.º 6
0
 /**
  * @dataProvider getExceptionProvider
  */
 function testGetException($extensions, $type, $name, $exxceptionName)
 {
     $this->setExpectedException($exxceptionName);
     $manager = new ExtensionManager();
     foreach ($extensions as $extension) {
         $manager->addExtension($extension['instance'], $extension['type']);
     }
     $manager->getExtension($type, $name);
 }
 function __construct(&$parent)
 {
     parent::__construct($parent);
     $this->_name = 'Member: Role';
     // Set default
     $this->set('show_column', 'no');
     $ExtensionManager = new ExtensionManager($this->_engine);
     $this->_driver = $ExtensionManager->create('members');
 }
 /**
  * Mediathek and Subsection Manager cannot be used simultaneously: 
  * This page deactivates one of these two extensions based on the context and returns to the extension overview.
  */
 public function build($context)
 {
     $ExtensionManager = new ExtensionManager(Administration::instance());
     // Deactivate extension
     if ($context[0] == 'mediathek' || $context[0] == 'subsectionmanager') {
         $ExtensionManager->disable($context[0]);
     }
     // Return to extension overview
     redirect(URL . '/symphony/system/extensions/');
 }
Ejemplo n.º 9
0
 function listAll()
 {
     $result = array();
     $people = array();
     $structure = General::listStructure(EVENTS, '/event.[\\w-]+.php/', false, 'ASC', EVENTS);
     if (is_array($structure['filelist']) && !empty($structure['filelist'])) {
         foreach ($structure['filelist'] as $f) {
             $f = self::__getHandleFromFilename($f);
             //preg_replace(array('/^event./i', '/.php$/i'), '', $f);
             if ($about = $this->about($f)) {
                 $classname = $this->__getClassName($f);
                 $path = $this->__getDriverPath($f);
                 $can_parse = false;
                 $type = NULL;
                 if (is_callable(array($classname, 'allowEditorToParse'))) {
                     $can_parse = @call_user_func(array(&$classname, 'allowEditorToParse'));
                 }
                 if (is_callable(array($classname, 'getType'))) {
                     $type = @call_user_func(array(&$classname, 'getType'));
                 }
                 $about['can_parse'] = $can_parse;
                 $about['type'] = $type;
                 $result[$f] = $about;
             }
         }
     }
     //$structure = General::listStructure(EXTENSIONS, array(), false, 'ASC', EXTENSIONS);
     //$extensions = $structure['dirlist'];
     $extensionManager = new ExtensionManager($this->_Parent);
     $extensions = $extensionManager->listInstalledHandles();
     if (is_array($extensions) && !empty($extensions)) {
         foreach ($extensions as $e) {
             if (!is_dir(EXTENSIONS . "/{$e}/events")) {
                 continue;
             }
             $tmp = General::listStructure(EXTENSIONS . "/{$e}/events", '/event.[\\w-]+.php/', false, 'ASC', EXTENSIONS . "/{$e}/events");
             if (is_array($tmp['filelist']) && !empty($tmp['filelist'])) {
                 foreach ($tmp['filelist'] as $f) {
                     $f = $f = self::__getHandleFromFilename($f);
                     if ($about = $this->about($f)) {
                         $classname = $this->__getClassName($f);
                         $can_parse = false;
                         $type = NULL;
                         $about['can_parse'] = $can_parse;
                         $about['type'] = $type;
                         $result[$f] = $about;
                     }
                 }
             }
         }
     }
     ksort($result);
     return $result;
 }
 public function __construct(\ExtensionManager $extensionManager, UserAccountModel $user)
 {
     foreach ($extensionManager->getExtensionsIncludingCore() as $extension) {
         $extID = $extension->getId();
         foreach ($extension->getUserNotificationPreferenceTypes() as $type) {
             $key = str_replace(".", "_", $extID . '.' . $type);
             $this->preferences[$key] = $extension->getUserNotificationPreference($type);
         }
     }
     $this->user = $user;
 }
 protected function __trigger()
 {
     $ExtensionManager = new ExtensionManager($this->_Parent);
     $driver = $ExtensionManager->create('members');
     $email = $_POST['member-email-address'];
     if ($members = $driver->findMemberIDFromEmail($email)) {
         foreach ($members as $member_id) {
             $driver->sendForgotPasswordEmail($member_id);
         }
     }
     return new XMLElement('forgot-password', 'Email sent', array('sent' => 'true'));
 }
 /**
  * Download language file
  */
 function build($context)
 {
     // Get context
     $name = $context[2];
     $lang = $context[1];
     $context = $context[0];
     // Get localisation strings
     $data = $this->LocalisationManager->buildDictionary($context, $lang, $name);
     // Load template
     $path = EXTENSIONS . '/localisationmanager/lib';
     if ($context == 'symphony') {
         $template = file_get_contents($path . '/lang.core.tpl');
     } else {
         $template = file_get_contents($path . '/lang.extension.tpl');
     }
     // Add data
     $template = str_replace('<!-- $name -->', $data['about']['name'], $template);
     $template = str_replace('<!-- $author -->', $data['about']['author']['name'], $template);
     $template = str_replace('<!-- $email -->', $data['about']['author']['email'], $template);
     $template = str_replace('<!-- $website -->', $data['about']['author']['website'], $template);
     $template = str_replace('<!-- $date -->', $data['about']['release-date'], $template);
     if ($context != 'symphony') {
         $ExtensionManager = new ExtensionManager($this->parent);
         $extensions = $ExtensionManager->listAll();
         $template = str_replace('<!-- $extension -->', $extensions[$context]['name'], $template);
     }
     $template = str_replace('<!-- $strings -->', $this->__layout($data['dictionary']['strings']), $template);
     $template = str_replace('<!-- $obsolete -->', $this->__layout($data['dictionary']['obsolete'], 'Obsolete'), $template);
     $template = str_replace('<!-- $missing -->', $this->__layout($data['dictionary']['missing'], 'Missing'), $template);
     $template = str_replace('<!-- $namespaces -->', $this->__layoutNamespace($data['dictionary']['namespaces']), $template);
     if ($context == 'symphony') {
         $template = str_replace('<!-- $uppercase -->', $this->__transliterations($data['transliterations']['straight']['uppercase'], 5), $template);
         $template = str_replace('<!-- $lowercase -->', $this->__transliterations($data['transliterations']['straight']['lowercase'], 5), $template);
         $template = str_replace('<!-- $symbolic -->', $this->__transliterations($data['transliterations']['straight']['symbolic'], 3), $template);
         $template = str_replace('<!-- $special -->', $this->__transliterations($data['transliterations']['straight']['special']), $template);
         $template = str_replace('<!-- $otherstraight -->', $this->__transliterations($data['transliterations']['straight']['other']), $template);
         $template = str_replace('<!-- $ampersands -->', $this->__transliterations($data['transliterations']['regexp']['ampersands']), $template);
         $template = str_replace('<!-- $otherregexp -->', $this->__transliterations($data['transliterations']['regexp']['other']), $template);
     }
     // Send file
     header('Content-Type: application/x-php; charset=utf-8');
     header('Content-Disposition: attachment; filename="lang.' . ($lang ? $lang : 'new') . '.php"');
     header("Content-Description: File Transfer");
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     echo $template;
     exit;
 }
Ejemplo n.º 13
0
Archivo: Parser.php Proyecto: g4z/poop
 protected function procMethodInvoke(Token $token)
 {
     $this->debug(__METHOD__, __LINE__, "Found a method call: {$token->getValue()}");
     $method = $token->getValue();
     // Checkout method is available
     if (!$this->extension_manager->resolve($method)) {
         throw new SyntaxException($token->getLine(), $token->getColumn(), 'Call to undefined method: ' . $token->getValue(), __FILE__, __LINE__);
     }
     // Begin processing ...
     $token = $this->getToken();
     if ($token->getValue() != '(') {
         throw new SyntaxException($token->getLine(), $token->getColumn(), "Expected '(' but got '{$token->getValue()}'", __FILE__, __LINE__);
     }
     $arguments = array();
     $token = $this->getToken();
     while ($token->getValue() != ')') {
         $value = NULL;
         switch ($token->getValue()) {
             case ',':
                 break;
             default:
                 $vartype = $this->evalExp($value, $token);
                 break;
         }
         // $arguments[] = array($value, $vartype);
         $arguments[] = $value;
         $token = $this->getToken();
     }
     return $this->extension_manager->call($method, $arguments);
 }
Ejemplo n.º 14
0
 private function __indexPage()
 {
     // Create the XML for the page:
     $xml = new XMLElement('data');
     $sectionsNode = new XMLElement('sections');
     $sm = new SectionManager($this);
     $sections = $sm->fetch();
     foreach ($sections as $section) {
         $sectionsNode->appendChild(new XMLElement('section', $section->get('name'), array('id' => $section->get('id'))));
     }
     $xml->appendChild($sectionsNode);
     // Check if the multilingual-field extension is installed:
     if (in_array('multilingual_field', ExtensionManager::listInstalledHandles())) {
         $xml->setAttribute('multilanguage', 'yes');
         // Get all the multilanguage fields:
         $fm = new FieldManager($this);
         $fields = $fm->fetch(null, null, 'ASC', 'sortorder', 'multilingual');
         $multilanguage = new XMLElement('multilanguage');
         foreach ($fields as $field) {
             $sectionID = $field->get('parent_section');
             $section = $sm->fetch($sectionID);
             $id = $field->get('id');
             $label = $section->get('name') . ' : ' . $field->get('label');
             $multilanguage->appendChild(new XMLElement('field', $label, array('id' => $id)));
         }
         $xml->appendChild($multilanguage);
     }
     // Generate the HTML:
     $xslt = new XSLTPage();
     $xslt->setXML($xml->generate());
     $xslt->setXSL(EXTENSIONS . '/importcsv/content/index.xsl', true);
     $this->Form->setValue($xslt->generate());
     $this->Form->setAttribute('enctype', 'multipart/form-data');
 }
 public function sort(&$sort, &$order, $params)
 {
     if (is_null($sort)) {
         $sort = 'name';
     }
     return ExtensionManager::fetch(array(), array(), $sort . ' ' . $order);
 }
Ejemplo n.º 16
0
 function __find($type)
 {
     if (@is_file(TOOLKIT . "/fields/field.{$type}.php")) {
         return TOOLKIT . '/fields';
     } else {
         $extensionManager = new ExtensionManager($this->_Parent);
         $extensions = $extensionManager->listInstalledHandles();
         if (is_array($extensions) && !empty($extensions)) {
             foreach ($extensions as $e) {
                 if (@is_file(EXTENSIONS . "/{$e}/fields/field.{$type}.php")) {
                     return EXTENSIONS . "/{$e}/fields";
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 17
0
 /**
  * Constructor
  *
  * Reads project's and default .ini file, sets project handler's 
  * and initializes paths.
  * @param location config file
  */
 public function __construct()
 {
     parent::__construct();
     $this->template = array();
     $this->templateFile = "extensionhandler.tpl";
     $this->basePath = realpath(dirname(__FILE__) . "/../") . "/";
     $this->renderExtension = false;
 }
 /**
  * Upgrade Mediathek fields to make use of this extension
  */
 public function __upgradeMediathek()
 {
     // Do not use Administration::instance() in this context, see:
     // http://github.com/nilshoerrmann/subsectionmanager/issues#issue/27
     $callback = $this->_Parent->getPageCallback();
     // Append upgrade notice
     if ($callback['driver'] == 'systemextensions') {
         require_once TOOLKIT . '/class.extensionmanager.php';
         $ExtensionManager = new ExtensionManager(Administration::instance());
         // Check if Mediathek field is installed
         $mediathek = $ExtensionManager->fetchStatus('mediathek');
         if ($mediathek == EXTENSION_ENABLED) {
             // Append upgrade notice to page
             Administration::instance()->Page->Alert = new Alert(__('You are using Mediathek and Subsection Manager simultaneously.') . ' <a href="http://' . DOMAIN . '/symphony/extension/subsectionmanager/">' . __('Upgrade') . '?</a> <a href="http://' . DOMAIN . '/symphony/extension/subsectionmanager/deactivate/mediathek">' . __('Disable Mediathek') . '</a> <a href="http://' . DOMAIN . '/symphony/extension/subsectionmanager/deactivate/subsectionmanager">' . __('Disable Subsection Manager') . '</a>', Alert::ERROR);
         }
     }
 }
function smarty_function_loadExtension($params, &$smarty)
{
    //fetch plugin name
    $extName = $params['name'];
    $config =& $params['config'];
    if (empty($extName)) {
        return "No Extension selected";
    }
    // now we got the name and the params so lets include and pass
    require_once $config->miplexDir . "ExtensionManager.class.php";
    $extManager = new ExtensionManager($config);
    $ext = $extManager->loadExtension($extName);
    if ($ext != false) {
        return $ext->main($extParams);
    } else {
        return "Plugin not Found";
    }
}
 /**
  * The processEvents function executes all Events attached to the resolved
  * page in the correct order determined by `__findEventOrder()`. The results
  * from the Events are appended to the page's XML. Events execute first,
  * before Datasources.
  *
  * @uses FrontendProcessEvents
  * @uses FrontendEventPostProcess
  * @param string $events
  *  A string of all the Events attached to this page, comma separated.
  * @param XMLElement $wrapper
  *  The XMLElement to append the Events results to. Event results are
  *  contained in a root XMLElement that is the handlised version of
  *  their name.
  */
 private function processEvents($events, XMLElement &$wrapper)
 {
     /**
      * Manipulate the events array and event element wrapper
      * @delegate FrontendProcessEvents
      * @param string $context
      * '/frontend/'
      * @param array $env
      * @param string $events
      *  A string of all the Events attached to this page, comma separated.
      * @param XMLElement $wrapper
      *  The XMLElement to append the Events results to. Event results are
      *  contained in a root XMLElement that is the handlised version of
      *  their name.
      * @param array $page_data
      *  An associative array of page meta data
      */
     $this->ExtensionManager->notifyMembers('FrontendProcessEvents', '/frontend/', array('env' => $this->_env, 'events' => &$events, 'wrapper' => &$wrapper, 'page_data' => $this->_pageData));
     if (strlen(trim($events)) > 0) {
         $events = preg_split('/,\\s*/i', $events, -1, PREG_SPLIT_NO_EMPTY);
         $events = array_map('trim', $events);
         if (!is_array($events) || empty($events)) {
             return;
         }
         $pool = array();
         foreach ($events as $handle) {
             $pool[$handle] = $this->EventManager->create($handle, array('env' => $this->_env, 'param' => $this->_param));
         }
         uasort($pool, array($this, '__findEventOrder'));
         foreach ($pool as $handle => $event) {
             Frontend::instance()->Profiler->seed();
             $dbstats = Symphony::Database()->getStatistics();
             $queries = $dbstats['queries'];
             if ($xml = $event->load()) {
                 if (is_object($xml)) {
                     $wrapper->appendChild($xml);
                 } else {
                     $wrapper->setValue($wrapper->getValue() . self::CRLF . '	' . trim($xml));
                 }
             }
             $dbstats = Symphony::Database()->getStatistics();
             $queries = $dbstats['queries'] - $queries;
             Frontend::instance()->Profiler->sample($handle, PROFILE_LAP, 'Event', $queries);
         }
     }
     /**
      * Just after the page events have triggered. Provided with the XML object
      * @delegate FrontendEventPostProcess
      * @param string $context
      * '/frontend/'
      * @param XMLElement $xml
      *  The XMLElement to append the Events results to. Event results are
      *  contained in a root XMLElement that is the handlised version of
      *  their name.
      */
     $this->ExtensionManager->notifyMembers('FrontendEventPostProcess', '/frontend/', array('xml' => &$wrapper));
 }
 public function load()
 {
     // In case of the page:
     if (isset($_GET['download'])) {
         header('Content-Disposition: attachment; filename=' . $_GET['download']);
     }
     // In case of a file:
     if (isset($_GET['file'])) {
         // include_once('event.force_download.config.php');
         $driver = ExtensionManager::getInstance('force_download');
         /* @var $driver extension_force_download */
         $allowedDirs = $driver->getLocations();
         $pathInfo = pathinfo($_GET['file']);
         // Check to see if the directory is allowed to direct-download from:
         $wildCardMatch = false;
         $info = pathinfo($_GET['file']);
         foreach ($allowedDirs as $allowedDir) {
             if (strstr($allowedDir, '/*') !== false) {
                 $match = str_replace('/*', '', $allowedDir);
                 if (strstr($match, $info['dirname']) !== false) {
                     $wildCardMatch = true;
                 }
             }
         }
         if (in_array($pathInfo['dirname'], $allowedDirs) || $wildCardMatch) {
             // Force the download:
             if (file_exists($_GET['file'])) {
                 // Determine the mimetype:
                 if (function_exists('mime_content_type')) {
                     $mimeType = mime_content_type($_GET['file']);
                 } elseif (function_exists('finfo_open')) {
                     $finfo = finfo_open(FILEINFO_MIME_TYPE);
                     $mimeType = finfo_file($finfo, $_GET['file']);
                 } else {
                     $mimeType = "application/force-download";
                 }
                 header('Content-Description: File Transfer');
                 header('Content-Type: ' . $mimeType);
                 header('Content-Disposition: attachment; filename=' . $pathInfo['basename']);
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 header('Pragma: public');
                 header('Content-Length: ' . filesize($_GET['file']));
                 ob_clean();
                 flush();
                 readfile($_GET['file']);
                 exit;
             } else {
                 die('File does not exist!');
             }
         } else {
             die('Permission denied!');
         }
     }
 }
Ejemplo n.º 22
0
 public function __construct()
 {
     parent::__construct();
     $this->_name = 'Entry URL';
     $this->_driver = ExtensionManager::create('entry_url_field');
     // Set defaults:
     $this->set('show_column', 'no');
     $this->set('new_window', 'no');
     $this->set('hide', 'no');
 }
 function __construct(ExtensionManager $extensionManager, $permissions, \models\UserAccountModel $userAccountModel = null, $removeEditorPermissions = false, $includeChildrenPermissions = false)
 {
     if ($userAccountModel) {
         $this->has_user = true;
         $this->has_user_editor = $userAccountModel->getIsEditor();
         $this->has_user_verified = $userAccountModel->getIsEmailVerified();
         $this->has_user_system_administrator = $userAccountModel->getIsSystemAdmin();
     }
     $this->removeEditorPermissions = $removeEditorPermissions;
     $this->permissions = array();
     // Add direct permissions, checking user stats as we do so.
     foreach ($permissions as $permission) {
         $this->addPermission($permission);
     }
     // now add children
     if ($includeChildrenPermissions) {
         $loopCount = 0;
         do {
             $loopCount++;
             $addedAny = false;
             foreach ($extensionManager->getExtensionsIncludingCore() as $extension) {
                 foreach ($extension->getUserPermissions() as $possibleChildID) {
                     $possibleChildPermission = $extension->getUserPermission($possibleChildID);
                     if (!$this->hasPermission($extension->getId(), $possibleChildID)) {
                         $addThisOne = false;
                         foreach ($possibleChildPermission->getParentPermissionsIDs() as $parentData) {
                             if (!$addThisOne && $this->hasPermission($parentData[0], $parentData[1])) {
                                 $addThisOne = true;
                             }
                         }
                         if ($addThisOne) {
                             $this->addPermission($possibleChildPermission);
                             $addedAny = true;
                         }
                     }
                 }
             }
         } while ($addedAny && $loopCount < 100);
     }
 }
 public function fetchAll()
 {
     $this->buildStart();
     $this->build();
     $this->buildStat();
     $results = array();
     while ($data = $this->stat->fetch()) {
         $extension = $this->extensionManager->getExtensionById($data['from_extension_id']);
         if ($extension) {
             $type = $extension->getUserNotificationType($data['from_user_notification_type']);
             if ($type) {
                 $site = new SiteModel();
                 $site->setId($data['site_id']);
                 $site->setSlug($data['site_slug']);
                 $site->setTitle($data['site_title']);
                 $notification = $type->getNotificationFromData($data, null, $site);
                 if ($notification->isValid()) {
                     $results[] = $notification;
                 }
             }
         }
     }
     return $results;
 }
Ejemplo n.º 25
0
 public function view()
 {
     header('Content-Type: text/xml');
     $response = new XMLElement('response');
     $id = $_GET['id'];
     $version = Symphony::Configuration()->get('version', 'symphony');
     // remove text followed by numbers e.g. 2.3beta2 or 2.3rc1
     $version = preg_replace("/[a-z]+[0-9]+/i", '', $version);
     // remove text e.g. 2.3beta
     $version = preg_replace("/[a-z]+/i", '', $version);
     $symphony_version = self::normaliseVersionNumber($version);
     $response->setAttribute('symphony-version', $symphony_version);
     if (empty($id)) {
         $response->setAttribute('error', '404');
         echo $response->generate();
         die;
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, sprintf('http://symphonyextensions.com/api/extensions/%s/', $id));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, 'extension_status; Symphony ' . Symphony::Configuration()->get('version', 'symphony'));
     curl_setopt($ch, CURLOPT_REFERER, URL);
     $xml = curl_exec($ch);
     if (!$xml) {
         $response->setAttribute('error', '404');
         echo $response->generate();
         die;
     }
     $extension = simplexml_load_string($xml);
     $compatibility = $extension->xpath("//compatibility/symphony[@version='" . $symphony_version . "']");
     $extensions = ExtensionManager::fetch();
     $current_version = $extensions[$id]['version'];
     $response->setAttribute('current-local-version', $current_version);
     if (count($compatibility) == 0) {
         $response->setAttribute('compatible-version-exists', 'no');
     } else {
         $latest_version = $compatibility[0]->attributes()->use;
         $github_url = $extension->xpath("//link[@rel='github:page']/@href");
         $extension_url = $extension->xpath("//link[@rel='site:extension']/@href");
         $response->setAttribute('compatible-version-exists', 'yes');
         $response->setAttribute('latest-url', (string) $github_url[0] . '/tree/' . $latest_version);
         $response->setAttribute('latest', $latest_version);
         $response->setAttribute('can-update', version_compare($latest_version, $current_version, '>') ? 'yes' : 'no');
         $response->setAttribute('extension-url', 'http://symphonyextensions.com' . (string) $extension_url[0]);
     }
     echo $response->generate();
     die;
 }
 public function getPermissionsForAnyVerifiedUserInSite(SiteModel $siteModel, $removeEditorPermissions = false, $includeChildrenPermissions = false)
 {
     global $DB, $CONFIG;
     $stat = $DB->prepare("SELECT permission_in_user_group.* FROM permission_in_user_group " . " JOIN user_group_information ON user_group_information.id = permission_in_user_group.user_group_id AND user_group_information.is_deleted = '0' AND user_group_information.is_in_index = '0' " . " JOIN user_group_in_site ON user_group_in_site.user_group_id = user_group_information.id AND user_group_in_site.site_id = :site_id AND user_group_in_site.removed_at IS NULL " . " WHERE permission_in_user_group.removed_at IS NULL AND (user_group_information.is_includes_verified_users = '1' OR user_group_information.is_includes_users = '1' OR user_group_information.is_includes_anonymous = '1' )");
     $stat->execute(array('site_id' => $siteModel->getId()));
     $permissions = array();
     while ($data = $stat->fetch()) {
         $ext = $this->extensionsManager->getExtensionById($data['extension_id']);
         if ($ext) {
             $per = $ext->getUserPermission($data['permission_key']);
             if ($per) {
                 $permissions[] = $per;
             }
         }
     }
     $user = new UserAccountModel();
     $user->setIsEditor(true);
     return new \UserPermissionsList($this->extensionsManager, $permissions, $user, $CONFIG->siteReadOnly || $removeEditorPermissions, $includeChildrenPermissions);
 }
Ejemplo n.º 27
0
 /**
  * Resizes an Image to a given maximum width and height.
  *
  * @param string  $file     - absolute image path
  * @param integer $width    - desired width of the image
  * @param integer $height   - desired height of the image
  * @param string  $mimetype - image type
  *
  * @return boolean - true if success, false otherwise
  */
 public static function resize($file, $width, $height, $mimetype)
 {
     $jit_status = ExtensionManager::fetchStatus(array('handle' => 'jit_image_manipulation'));
     // process image using JIT mode 1
     if ($jit_status[0] === EXTENSION_ENABLED) {
         require_once EXTENSIONS . '/jit_image_manipulation/lib/class.image.php';
         try {
             $image = Image::load($file);
             // if not and Image, stick with original version
             if (!$image instanceof Image) {
                 return false;
             }
         } catch (Exception $e) {
             return false;
         }
         $image->applyFilter('resize', array($width, $height));
         $image->save($file, 85, null, $mimetype);
     }
     return true;
 }
Ejemplo n.º 28
0
 function view()
 {
     $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70);
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if ($formHasErrors) {
         $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR);
     }
     $this->setPageType('form');
     $this->appendSubheading('Untitled');
     $fields = array();
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
     }
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', 'Essentials'));
     $label = Widget::Label('Name');
     $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name'])));
     if (isset($this->_errors['name'])) {
         $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name']));
     } else {
         $fieldset->appendChild($label);
     }
     $this->Form->appendChild($fieldset);
     $EventManager = new EventManager($this->_Parent);
     $events = $EventManager->listAll();
     if (is_array($events) && !empty($events)) {
         foreach ($events as $handle => $e) {
             if (!$e['can_parse']) {
                 unset($events[$handle]);
             }
         }
     }
     if (is_array($events) && !empty($events)) {
         $fieldset = new XMLElement('fieldset');
         $fieldset->setAttribute('class', 'settings type-file');
         $fieldset->appendChild(new XMLElement('legend', 'Event Level Permissions'));
         $aTableHead = array(array('Event', 'col'), array('Add', 'col'), array('Edit', 'col'), array('Delete', 'col'));
         $aTableBody = array();
         foreach ($events as $event_handle => $event) {
             $permissions = $fields['permissions'][$event_handle];
             ## Setup each cell
             $td1 = Widget::TableData($event['name']);
             $td2 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][add]', 'yes', 'checkbox', isset($permissions['add']) ? array('checked' => 'checked') : NULL));
             $td3 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][edit]', 'yes', 'checkbox', isset($permissions['edit']) ? array('checked' => 'checked') : NULL));
             $td4 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][delete]', 'yes', 'checkbox', isset($permissions['delete']) ? array('checked' => 'checked') : NULL));
             ## Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4));
         }
         $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'role-permissions');
         $fieldset->appendChild($table);
         $this->Form->appendChild($fieldset);
     }
     ####
     # Delegate: MemberRolePermissionFieldsetsNew
     # Description: Add custom fieldsets to the role page
     $ExtensionManager = new ExtensionManager($this->_Parent);
     $ExtensionManager->notifyMembers('MemberRolePermissionFieldsetsNew', '/extension/members/new/', array('form' => &$this->Form, 'permissions' => $fields['permissions']));
     #####
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', 'Page Level Permissions'));
     $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` " . ($this->_context[0] == 'edit' ? "WHERE `id` != '{$page_id}' " : '') . "ORDER BY `title` ASC");
     $label = Widget::Label('Allow Access');
     $options = array();
     if (is_array($pages) && !empty($pages)) {
         foreach ($pages as $page) {
             $options[] = array($page['id'], in_array($page['id'], $fields['page_access']), '/' . $this->_Parent->resolvePagePath($page['id']));
             //$page['title']);
         }
     }
     $label->appendChild(Widget::Select('fields[page_access][]', $options, array('multiple' => 'multiple')));
     $fieldset->appendChild($label);
     $this->Form->appendChild($fieldset);
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings type-file');
     $fieldset->appendChild(new XMLElement('legend', 'Email Template'));
     $fieldset->appendChild(new XMLElement('p', 'When adding a member, they will receive an email based on the template you specify. <br /><br />Leave everything blank if you do not wish for new members in this group to receive an email.', array('class' => 'help')));
     $label = Widget::Label('Subject');
     $label->appendChild(Widget::Input('fields[email_subject]', General::sanitize($fields['email_subject'])));
     if (isset($this->_errors['email_subject'])) {
         $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['email_subject']));
     } else {
         $fieldset->appendChild($label);
     }
     $label = Widget::Label('Body');
     $label->appendChild(Widget::Textarea('fields[email_body]', '25', '50', General::sanitize($fields['email_body'])));
     $fieldset->appendChild(isset($this->_errors['email_body']) ? $this->wrapFormElementWithError($label, $this->_errors['email_body']) : $label);
     $fieldset->appendChild(new XMLElement('p', 'You can add dynamic elements to the email by using <code>{$field-name}</code> syntax, where <code>field-name</code> corresponds to the fields of the new member.', array('class' => 'help')));
     $this->Form->appendChild($fieldset);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', 'Create', 'submit', array('accesskey' => 's')));
     $this->Form->appendChild($div);
 }
Ejemplo n.º 29
0
 /**
  * @param null $customPath
  * @return array|mixed
  */
 public static function getBrickDirectories($customPath = null)
 {
     $cacheKey = "brick_directories";
     if ($customPath) {
         $cacheKey .= "_" . crc32($customPath);
     }
     $areas = array();
     try {
         $areas = \Zend_Registry::get($cacheKey);
     } catch (\Exception $e) {
         if ($customPath) {
             $areaRepositories = array($customPath);
         } else {
             $areaRepositories = array(PIMCORE_WEBSITE_PATH . "/views/areas", PIMCORE_WEBSITE_VAR . "/areas");
         }
         // include area repositories from active plugins
         $configs = ExtensionManager::getPluginConfigs();
         foreach ($configs as $config) {
             $className = $config["plugin"]["pluginClassName"];
             if (!empty($className)) {
                 $isEnabled = ExtensionManager::isEnabled("plugin", $config["plugin"]["pluginName"]);
                 $areaDir = PIMCORE_PLUGINS_PATH . "/" . $config["plugin"]["pluginName"] . "/views/areas";
                 if ($isEnabled && file_exists($areaDir)) {
                     $areaRepositories[] = $areaDir;
                 }
             }
         }
         // get directories
         foreach ($areaRepositories as $respository) {
             if (is_dir($respository) && is_readable($respository)) {
                 $blockDirs = scandir($respository);
                 foreach ($blockDirs as $blockDir) {
                     if (is_dir($respository . "/" . $blockDir)) {
                         if (is_file($respository . "/" . $blockDir . "/area.xml")) {
                             $areas[$blockDir] = $respository . "/" . $blockDir;
                         }
                     }
                 }
             }
         }
         \Zend_Registry::set($cacheKey, $areas);
     }
     return $areas;
 }
Ejemplo n.º 30
0
 private static function __install()
 {
     $fields = $_POST['fields'];
     $start = time();
     Symphony::Log()->writeToLog(PHP_EOL . '============================================', true);
     Symphony::Log()->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true);
     Symphony::Log()->writeToLog('============================================', true);
     // MySQL: Establishing connection
     Symphony::Log()->pushToLog('MYSQL: Establishing Connection', E_NOTICE, true, true);
     try {
         Symphony::Database()->connect($fields['database']['host'], $fields['database']['user'], $fields['database']['password'], $fields['database']['port'], $fields['database']['db']);
     } catch (DatabaseException $e) {
         self::__abort('There was a problem while trying to establish a connection to the MySQL server. Please check your settings.', $start);
     }
     // MySQL: Setting prefix & character encoding
     Symphony::Database()->setPrefix($fields['database']['tbl_prefix']);
     Symphony::Database()->setCharacterEncoding();
     Symphony::Database()->setCharacterSet();
     // MySQL: Importing schema
     Symphony::Log()->pushToLog('MYSQL: Importing Table Schema', E_NOTICE, true, true);
     try {
         Symphony::Database()->import(file_get_contents(INSTALL . '/includes/install.sql'), true);
     } catch (DatabaseException $e) {
         self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
     }
     // MySQL: Creating default author
     Symphony::Log()->pushToLog('MYSQL: Creating Default Author', E_NOTICE, true, true);
     try {
         Symphony::Database()->insert(array('id' => 1, 'username' => Symphony::Database()->cleanValue($fields['user']['username']), 'password' => Cryptography::hash(Symphony::Database()->cleanValue($fields['user']['password'])), 'first_name' => Symphony::Database()->cleanValue($fields['user']['firstname']), 'last_name' => Symphony::Database()->cleanValue($fields['user']['lastname']), 'email' => Symphony::Database()->cleanValue($fields['user']['email']), 'last_seen' => NULL, 'user_type' => 'developer', 'primary' => 'yes', 'default_area' => NULL, 'auth_token_active' => 'no'), 'tbl_authors');
     } catch (DatabaseException $e) {
         self::__abort('There was an error while trying create the default author. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
     }
     // Configuration: Populating array
     $conf = Symphony::Configuration()->get();
     foreach ($conf as $group => $settings) {
         foreach ($settings as $key => $value) {
             if (isset($fields[$group]) && isset($fields[$group][$key])) {
                 $conf[$group][$key] = $fields[$group][$key];
             }
         }
     }
     // Create manifest folder structure
     Symphony::Log()->pushToLog('WRITING: Creating ‘manifest’ folder (/manifest)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘manifest’ directory. Check permission on the root folder.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘logs’ folder (/manifest/logs)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/logs', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘logs’ directory. Check permission on /manifest.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘cache’ folder (/manifest/cache)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/cache', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘cache’ directory. Check permission on /manifest.', $start);
     }
     Symphony::Log()->pushToLog('WRITING: Creating ‘tmp’ folder (/manifest/tmp)', E_NOTICE, true, true);
     if (!General::realiseDirectory(DOCROOT . '/manifest/tmp', $conf['directory']['write_mode'])) {
         self::__abort('Could not create ‘tmp’ directory. Check permission on /manifest.', $start);
     }
     // Writing configuration file
     Symphony::Log()->pushToLog('WRITING: Configuration File', E_NOTICE, true, true);
     Symphony::Configuration()->setArray($conf);
     if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) {
         self::__abort('Could not create config file ‘' . CONFIG . '’. Check permission on /manifest.', $start);
     }
     // Writing htaccess file
     Symphony::Log()->pushToLog('CONFIGURING: Frontend', E_NOTICE, true, true);
     $rewrite_base = ltrim(preg_replace('/\\/install$/i', NULL, dirname($_SERVER['PHP_SELF'])), '/');
     $htaccess = str_replace('<!-- REWRITE_BASE -->', $rewrite_base, file_get_contents(INSTALL . '/includes/htaccess.txt'));
     if (!General::writeFile(DOCROOT . "/.htaccess", $htaccess, $conf['file']['write_mode'], 'a')) {
         self::__abort('Could not write ‘.htaccess’ file. Check permission on ' . DOCROOT, $start);
     }
     // Writing /workspace folder
     if (!is_dir(DOCROOT . '/workspace')) {
         // Create workspace folder structure
         Symphony::Log()->pushToLog('WRITING: Creating ‘workspace’ folder (/workspace)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘data-sources’ folder (/workspace/data-sources)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/data-sources', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/data-sources’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘events’ folder (/workspace/events)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/events', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/events’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘pages’ folder (/workspace/pages)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/pages', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/pages’ directory. Check permission on the root folder.', $start);
         }
         Symphony::Log()->pushToLog('WRITING: Creating ‘utilities’ folder (/workspace/utilities)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/workspace/utilities', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘workspace/utilities’ directory. Check permission on the root folder.', $start);
         }
     } else {
         Symphony::Log()->pushToLog('An existing ‘workspace’ directory was found at this location. Symphony will use this workspace.', E_NOTICE, true, true);
         // MySQL: Importing workspace data
         Symphony::Log()->pushToLog('MYSQL: Importing Workspace Data...', E_NOTICE, true, true);
         if (is_file(DOCROOT . '/workspace/install.sql')) {
             try {
                 Symphony::Database()->import(file_get_contents(DOCROOT . '/workspace/install.sql'), $fields['database']['use-server-encoding'] != 'yes' ? true : false, true);
             } catch (DatabaseException $e) {
                 self::__abort('There was an error while trying to import data to the database. MySQL returned: ' . $e->getDatabaseErrorCode() . ': ' . $e->getDatabaseErrorMessage(), $start);
             }
         }
     }
     // Write extensions folder
     if (!is_dir(DOCROOT . '/extensions')) {
         // Create extensions folder
         Symphony::Log()->pushToLog('WRITING: Creating ‘extensions’ folder (/extensions)', E_NOTICE, true, true);
         if (!General::realiseDirectory(DOCROOT . '/extensions', $conf['directory']['write_mode'])) {
             self::__abort('Could not create ‘extension’ directory. Check permission on the root folder.', $start);
         }
     }
     // Install existing extensions
     Symphony::Log()->pushToLog('CONFIGURING: Installing existing extensions', E_NOTICE, true, true);
     $disabled_extensions = array();
     foreach (new DirectoryIterator(EXTENSIONS) as $e) {
         if ($e->isDot() || $e->isFile() || !is_file($e->getRealPath() . '/extension.driver.php')) {
             continue;
         }
         $handle = $e->getBasename();
         try {
             if (!ExtensionManager::enable($handle)) {
                 $disabled_extensions[] = $handle;
                 Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’.', E_NOTICE, true, true);
             }
         } catch (Exception $ex) {
             $disabled_extensions[] = $handle;
             Symphony::Log()->pushToLog('Could not enable the extension ‘' . $handle . '’. ' . $ex->getMessage(), E_NOTICE, true, true);
         }
     }
     // Loading default language
     if (isset($_REQUEST['lang']) && $_REQUEST['lang'] != 'en') {
         Symphony::Log()->pushToLog('CONFIGURING: Default language', E_NOTICE, true, true);
         $language = Lang::Languages();
         $language = $language[$_REQUEST['lang']];
         // Is the language extension enabled?
         if (in_array('lang_' . $language['handle'], ExtensionManager::listInstalledHandles())) {
             Symphony::Configuration()->set('lang', $_REQUEST['lang'], 'symphony');
             if (!Symphony::Configuration()->write(CONFIG, $conf['file']['write_mode'])) {
                 Symphony::Log()->pushToLog('Could not write default language ‘' . $language['name'] . '’ to config file.', E_NOTICE, true, true);
             }
         } else {
             Symphony::Log()->pushToLog('Could not enable the desired language ‘' . $language['name'] . '’.', E_NOTICE, true, true);
         }
     }
     // Installation completed. Woo-hoo!
     Symphony::Log()->writeToLog('============================================', true);
     Symphony::Log()->writeToLog(sprintf('INSTALLATION COMPLETED: Execution Time - %d sec (%s)', max(1, time() - $start), date('d.m.y H:i:s')), true);
     Symphony::Log()->writeToLog('============================================' . PHP_EOL . PHP_EOL . PHP_EOL, true);
     return $disabled_extensions;
 }