public function index()
 {
     $clientId = $this->userRepository->find(Auth::user()->id)->client->id;
     $orders = $this->repository->scopeQuery(function ($query) use($clientId) {
         return $query->where('client_id', '=', $clientId);
     })->paginate();
     return view('customer.order.index', compact('orders'));
 }
Ejemplo n.º 2
0
function shutdown()
{
    global $db, $repoinprogress;
    if ($repoinprogress) {
        echo "DISTRUZIONE REPOSITORY ({$repoinprogress}) in corso...";
        $rep = new repository($repoinprogress);
        $repoinprogress = 0;
        $rep->drop();
        echo "REPOSITORY DISTRUTTO.";
    }
    echo "Chiusura applicazione";
    flush();
}
Ejemplo n.º 3
0
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     if (empty($this->root_path)) {
         return;
     }
     $this->root_path = trim($this->root_path);
     if (!empty($options['ajax'])) {
         // if created from filepicker
         if (empty($this->root_path)) {
             $ret = array();
             $ret['msg'] = get_string('invalidpath', 'repository_filesystem');
             $ret['nosearch'] = true;
             echo json_encode($ret);
             exit;
         } else {
             if (!is_dir($this->root_path)) {
                 $ret = array();
                 $ret['msg'] = get_string('invalidpath', 'repository_filesystem');
                 $ret['nosearch'] = true;
                 if ($options['ajax']) {
                     echo json_encode($ret);
                     exit;
                 }
             }
         }
         if ($this->root_path[strlen($this->root_path) - 1] !== '/') {
             $this->root_path .= '/';
         }
     }
 }
Ejemplo n.º 4
0
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     // set up webdav client
     $this->wd = new webdav_client();
     if (empty($this->options['webdav_server'])) {
         return;
     }
     if (empty($this->options['webdav_type'])) {
         $this->options['webdav_type'] = '';
     } else {
         $this->options['webdav_type'] = 'ssl://';
     }
     $this->wd->set_server($this->options['webdav_server']);
     if (empty($this->options['webdav_port'])) {
         if (empty($this->options['webdav_type'])) {
             $this->wd->set_port(80);
         } else {
             $this->wd->set_port(443);
         }
         $port = '';
     } else {
         $this->wd->set_port($this->options['webdav_port']);
         $port = ':' . $this->options['webdav_port'];
     }
     $this->webdav_host = $this->options['webdav_type'] . $this->options['webdav_server'] . $port;
     if (!empty($this->options['webdav_user'])) {
         $this->wd->set_user($this->options['webdav_user']);
     }
     if (!empty($this->options['webdav_password'])) {
         $this->wd->set_pass($this->options['webdav_password']);
     }
     $this->wd->set_protocol(1);
     $this->wd->set_debug(false);
 }
Ejemplo n.º 5
0
/**
 * Upgrade function.
 *
 * @param int $oldversion the version we are upgrading from.
 * @return bool result
 */
function xmldb_repository_alfresco_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2014020301) {
        require_once $CFG->dirroot . '/repository/lib.php';
        require_once $CFG->dirroot . '/repository/alfresco/db/upgradelib.php';
        $params = array();
        $params['context'] = array();
        $params['onlyvisible'] = false;
        $params['type'] = 'alfresco';
        $instances = repository::get_instances($params);
        // Notify the admin about the migration process if they are using the repo.
        if (!empty($instances)) {
            repository_alfresco_admin_security_key_notice();
        }
        upgrade_plugin_savepoint(true, 2014020301, 'repository', 'alfresco');
    }
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Ejemplo n.º 6
0
 public function createdb()
 {
     if (!$this->dropdb()) {
         return false;
     }
     if (!$this->db->query(repository::sql())) {
         return false;
     }
     if (!$this->db->query(package::sql())) {
         return false;
     }
     if (!$this->db->query(filelist::sql())) {
         return false;
     }
     if (!$this->db->query(guestbook::sql())) {
         return false;
     }
     if (!$this->db->query("\n\t\t  CREATE TABLE IF NOT EXISTS #__mixed (\n\t\t    field VARCHAR( 255 ) NOT NULL ,\n                    value VARCHAR( 255 ) NULL ,\n                    PRIMARY KEY ( field )\n\t\t  ) ENGINE = MyISAM;\n\t\t")) {
         return false;
     }
     if (!$this->db->query("\n\t\t  CREATE TABLE IF NOT EXISTS #__searches (\n\t\t    dt    DATETIME,\n\t\t    sname VARCHAR(50),\n\t\t    sdesc VARCHAR(50),\n\t\t    sfile VARCHAR(50),\n\t\t    ip    VARCHAR(15),\n\t\t    srepo INT,\n\t\t    results INT,\n\t\t    duration INT\n\t\t  ) ENGINE = MyISAM;\n\t        ")) {
         return false;
     }
     $this->db->query("INSERT INTO #__mixed (field,value) value ('count_visits','1');");
     $this->db->query("INSERT INTO #__mixed (field,value) value ('count_searches','1');");
     $this->db->query("INSERT INTO #__mixed (field,value) value ('count_srctxt','1');");
     $this->db->query("INSERT INTO #__mixed (field,value) value ('count_srcxml','1');");
     return true;
 }
Ejemplo n.º 7
0
 /**
  * Constructor, this constructor should be called ONLY from the file_storage class!
  *
  * @param file_storage $fs file  storage instance
  * @param stdClass $file_record description of file
  * @param string $filedir location of file directory with sh1 named content files
  */
 public function __construct(file_storage $fs, stdClass $file_record, $filedir)
 {
     global $DB, $CFG;
     $this->fs = $fs;
     $this->file_record = clone $file_record;
     // prevent modifications
     $this->filedir = $filedir;
     // keep secret, do not expose!
     if (!empty($file_record->repositoryid)) {
         require_once "{$CFG->dirroot}/repository/lib.php";
         $this->repository = repository::get_repository_by_id($file_record->repositoryid, SYSCONTEXTID);
         if ($this->repository->supported_returntypes() & FILE_REFERENCE != FILE_REFERENCE) {
             // Repository cannot do file reference.
             throw new moodle_exception('error');
         }
     } else {
         $this->repository = null;
     }
     // make sure all reference fields exist in file_record even when it is not a reference
     foreach (array('referencelastsync', 'referencefileid', 'reference', 'repositoryid') as $key) {
         if (empty($this->file_record->{$key})) {
             $this->file_record->{$key} = null;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Youtube plugin constructor
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     $this->start = 1;
     $this->max = 27;
     $this->sort = optional_param('youtube_sort', 'relevance', PARAM_TEXT);
     parent::__construct($repositoryid, $context, $options);
 }
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     // set up webdav client
     if (empty($this->options['webdav_server'])) {
         return;
     }
     if ($this->options['webdav_auth'] == 'none') {
         $this->options['webdav_auth'] = false;
     }
     $this->dav = new webdav_client($this->options['webdav_server'], $this->options['webdav_user'], $this->options['webdav_password'], $this->options['webdav_auth']);
     if (empty($this->options['webdav_type'])) {
         $this->webdav_type = '';
     } else {
         $this->webdav_type = 'ssl://';
     }
     if (empty($this->options['webdav_port'])) {
         if (empty($this->webdav_type)) {
             $this->dav->port = 80;
         } else {
             $this->dav->port = 443;
         }
         $port = '';
     } else {
         $this->dav->port = $this->options['webdav_port'];
         $port = ':' . $this->options['webdav_port'];
     }
     $this->webdav_host = $this->webdav_type . $this->options['webdav_server'] . $port;
     $this->dav->debug = false;
 }
Ejemplo n.º 10
0
 /**
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     global $CFG;
     parent::__construct($repositoryid, $context, $options);
     $this->file_url = optional_param('file', '', PARAM_RAW);
     $this->file_url = $this->escape_url($this->file_url);
 }
Ejemplo n.º 11
0
 public function __construct($repositoryid = 9, $context = SYSCONTEXTID, $options = array(), $readonly = 0)
 {
     global $USER, $COURSE, $DB;
     $this->repositoryid = $repositoryid;
     $this->context = $context;
     $this->options = $options;
     $this->readonly = $readonly;
     $this->useremail = $COURSE->shortname . '@luther.edu';
     if (!($this->admin = get_config('morsle', 'google_admin'))) {
         throw new moodle_exception('Google admin not setup');
     }
     parent::__construct($this->repositoryid, $this->context, $this->options, $this->readonly);
     // days past last enrollment day that morsle resources are retained
     $this->expires = get_config('morsle', 'morsle_expiration') == 0 ? 600 * 24 * 60 * 60 : get_config('blocks/morsle', 'morsle_expiration') * 24 * 60 * 60;
     $this->curtime = time();
     // set basefeeds
     $this->user_auth = "https://www.googleapis.com/auth/admin.directory.user";
     $this->site_feed = "https://sites.google.com/feeds/site/{$this->domain}";
     $this->drive_auth = 'https://www.googleapis.com/auth/drive ';
     $this->file_auth = 'https://www.googleapis.com/auth/drive.file ';
     $this->alias_feed = "https://apps-apis.google.com/a/feeds/alias/2.0/{$this->domain}/?start=aaaarnold@luther.edu";
     $this->group_auth = 'https://www.googleapis.com/auth/admin.directory.group';
     $this->id_feed = 'https://docs.google.com/feeds/id/';
     $this->cal_auth = 'https://www.googleapis.com/auth/calendar';
     $this->owncalendars_feed = 'https://www.google.com/calendar/feeds/default/owncalendars/full';
     // skip marked for delete, unapproved and past term
     $this->disregard = "'Past Term','DELETED'";
 }
Ejemplo n.º 12
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
     if (empty($this->keyword)) {
         $this->keyword = optional_param('s', '', PARAM_RAW);
     }
 }
Ejemplo n.º 13
0
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     $this->keyword = optional_param('youtube_keyword', '', PARAM_RAW);
     $this->start = 1;
     $this->max = 27;
     $this->sort = 'published';
     parent::__construct($repositoryid, $context, $options);
 }
Ejemplo n.º 14
0
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     $options['keyword'] = optional_param('youtube_keyword', '', PARAM_RAW);
     $options['start'] = 1;
     $options['max'] = 27;
     $options['sort'] = 'relevance';
     parent::__construct($repositoryid, $context, $options);
 }
Ejemplo n.º 15
0
 /**
  *
  * @global <type> $CFG
  * @param <type> $encodedpath
  * @param <type> $search
  * @return <type>
  */
 public function get_listing($encodedpath = '', $page = '', $search = '')
 {
     global $CFG;
     try {
         return repository::get_user_file_tree($search);
     } catch (Exception $e) {
         throw new repository_exception('emptyfilelist', 'repository_local');
     }
 }
Ejemplo n.º 16
0
 /**
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     global $CFG;
     parent::__construct($repositoryid, $context, $options);
     if (!empty($options['client_id'])) {
         // will be used to construct download form
         $this->client_id = $options['client_id'];
     }
     $this->file_url = optional_param('file', '', PARAM_RAW);
 }
Ejemplo n.º 17
0
 /**
  *
  * @global object $SESSION
  * @global string $action
  * @global object $CFG
  * @param int $repositoryid
  * @param object $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     global $SESSION, $action, $CFG;
     parent::__construct($repositoryid, $context, $options);
     $itemid = optional_param('itemid', '', PARAM_INT);
     if ($action == 'upload') {
         $filepath = '/';
         $this->info = repository::store_to_filepool('repo_upload_file', 'user_draft', $filepath, $itemid);
     }
 }
Ejemplo n.º 18
0
    /**
     * Constructor
     *
     * @param int $repositoryid repository instance id
     * @param int|stdClass $context a context id or context object
     * @param array $options repository options
     */
    public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
        parent::__construct($repositoryid, $context, $options);

        if (isset($this->options['mimetypes'])) {
            $mt = $this->options['mimetypes'];
            if (!empty($mt) && is_array($mt) && !in_array('*', $mt)) {
                $this->mimetypes = array_unique(array_map(array($this, 'to_mime_type'), $mt));
            }
        }
    }
Ejemplo n.º 19
0
 public function __construct($repositoryid, $context = SITEID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $this->access_key = get_config('s3', 'access_key');
     $this->secret_key = get_config('s3', 'secret_key');
     if (empty($this->access_key)) {
         die(json_encode(array('e' => get_string('repository_s3', 'needaccesskey'))));
     }
     $this->s = new S3($this->access_key, $this->secret_key);
 }
Ejemplo n.º 20
0
 public function toHtml()
 {
     global $CFG, $COURSE, $USER, $PAGE, $OUTPUT;
     $id = $this->_attributes['id'];
     $elname = $this->_attributes['name'];
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     }
     if (!($draftitemid = (int) $this->getValue())) {
         // no existing area info provided - let's use fresh new draft area
         $draftitemid = file_get_unused_draft_itemid();
         $this->setValue($draftitemid);
     }
     if ($COURSE->id == SITEID) {
         $context = context_system::instance();
     } else {
         $context = context_course::instance($COURSE->id);
     }
     $client_id = uniqid();
     $args = new stdClass();
     // Need these three to filter repositories list.
     $args->accepted_types = $this->_options['accepted_types'] ? $this->_options['accepted_types'] : '*';
     $args->return_types = $this->_options['return_types'];
     $args->itemid = $draftitemid;
     $args->maxbytes = 0;
     $args->context = $PAGE->context;
     $args->buttonname = $elname . 'choose';
     $args->elementname = $elname;
     // We can only tell the filepicker that we want FILE_REFERENCE repos
     // and which specific repo types we don't want. So here we build a list
     // of all FILE_REFERENCE supplying repos that aren't thebox to force
     // it to only display that one.
     $refrepos = repository::get_instances(array('currentcontext' => $PAGE->context, 'return_types' => FILE_REFERENCE));
     $disabled = array();
     foreach ($refrepos as $repo) {
         if (($name = $repo->get_typename()) != $this->repo) {
             $disabled[] = $name;
         }
     }
     $args->disable_types = $disabled;
     $html = $this->_getTabs();
     $fp = new file_picker($args);
     $options = $fp->options;
     $options->context = $PAGE->context;
     $html .= $OUTPUT->render($fp);
     $html .= '<input type="hidden" name="' . $elname . '" id="' . $id . '" value="' . $draftitemid . '" class="filepickerhidden"/>';
     $module = array('name' => 'form_filepicker', 'fullpath' => '/lib/form/filepicker.js', 'requires' => array('core_filepicker', 'node', 'node-event-simulate', 'core_dndupload'));
     $PAGE->requires->js_init_call('M.form_filepicker.init', array($fp->options), true, $module);
     $nonjsfilepicker = new moodle_url('/repository/draftfiles_manager.php', array('env' => 'filepicker', 'action' => 'browse', 'itemid' => $draftitemid, 'subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1, 'ctx_id' => $PAGE->context->id, 'course' => $PAGE->course->id, 'sesskey' => sesskey()));
     // non js file picker
     $html .= '<noscript>';
     $html .= "<div><object type='text/html' data='{$nonjsfilepicker}' height='160' width='600' style='border:1px solid #000'></object></div>";
     $html .= '</noscript>';
     return $html;
 }
Ejemplo n.º 21
0
function redefrepo($reposelected = 0)
{
    global $defrepo, $classes, $npackages;
    $defrepo = array();
    $classes = array();
    $repo = new repository();
    $nrepos = $repo->find();
    while ($repo->fetch()) {
        $id = $repo->id;
        $defrepo[$id] = (array) $repo;
        unset($defrepo[$id]["db"]);
        $defrepo[$id]['selected'] = $id == $reposelected;
        $classes[$repo->class]['class'] = $repo->class;
        $classes[$repo->class]['arch'] = $repo->arch;
        $classes[$repo->class]['version'] = $repo->version;
        $classes[$repo->class]['selected'] = $repo->class == $reposelected;
        $classes[$repo->class]['repo'][] = $repo->id;
        $npackages += $repo->npkgs;
    }
    echo "<table border='0' width='100%'>";
    echo "<tr>";
    echo "<td>";
    echo "You are the " . $_SESSION['searcher_visitor'] . "st visitor<br />";
    echo "Searched " . $GLOBALS['db']->counter_get('searches') . " packages from 24 Apr 2012<br /><br />";
    echo "<code>{$nrepos} repositories ({$npackages} packages)</code><br><br>\n";
    echo "</td>";
    $stats = new stats();
    $names = $stats->lastsearch(15);
    echo "<td>";
    echo "<table border=1 cellspacing=0>";
    echo "<tr><td colspan=3 align=center><code><b><a href='stats.php'>Recents</a></b></code></td></tr>";
    echo "<tr><td><code>", $names[0] . "<br />" . $names[1] . "<br />" . $names[2] . "<br />" . $names[3] . "<br />" . $names[4] . "</code></td>";
    echo "<td><code>", $names[5] . "<br />" . $names[6] . "<br />" . $names[7] . "<br />" . $names[8] . "<br />" . $names[9] . "</code></td>";
    echo "<td><code>", $names[10] . "<br />" . $names[11] . "<br />" . $names[12] . "<br />" . $names[13] . "<br />" . $names[14] . "</code></td></tr>";
    echo "</table>";
    echo "</td>";
    echo "<td>";
    echo "<table border=1 cellspacing=0 cellpadding=0>";
    echo "<tr><td><a href='stats.php'><img border=0 src='stats.php?gdaily&y=95&time=60&mid=0'></a></td></tr>";
    echo "</table>";
    echo "</tr></table>";
}
Ejemplo n.º 22
0
 public function logout()
 {
     global $USER;
     $token = google_picasa::get_sesskey($USER->id);
     $gauth = new google_authsub($token);
     // revoke token from google
     $gauth->revoke_session_token();
     google_picasa::delete_sesskey($USER->id);
     $this->subauthtoken = '';
     return parent::logout();
 }
Ejemplo n.º 23
0
 public static function type_config_form($mform, $classname = 'repository')
 {
     $a = new stdClass();
     $a->callbackurl = google_oauth::callback_url()->out(false);
     $mform->addElement('static', null, '', get_string('oauthinfo', 'repository_skydrive', $a));
     parent::type_config_form($mform);
     $strrequired = get_string('required');
     $mform->addElement('text', 'clientid', get_string('clientid', 'repository_skydrive'));
     $mform->addElement('text', 'secret', get_string('secret', 'repository_skydrive'));
     $mform->addRule('clientid', $strrequired, 'required', null, 'client');
     $mform->addRule('secret', $strrequired, 'required', null, 'client');
 }
 public function getServiceByCode($code)
 {
     $criteria = array(new Criterion\ContentTypeIdentifier(array('service_link')), new Criterion\Visibility(Criterion\Visibility::VISIBLE), new Criterion\Field('code', Criterion\Operator::EQ, $code));
     $query = new Query();
     $query->filter = new Criterion\LogicalAnd($criteria);
     $searchResult = $this->repository->getSearchService()->findContent($query);
     if (isset($searchResult->searchHits)) {
         return $searchResult->searchHits;
     } else {
         return array();
     }
 }
 public static function getPublicClientFromSession($repositoryid)
 {
     global $SESSION;
     // Get the Soap Client connection to the Hive web services from the session
     $publicClient = unserialize($SESSION->{'publicClient' . $repositoryid});
     if (empty($publicClient)) {
         $options = repository::get_instance($repositoryid)->options;
         $publicClient = self::getPublicClient($options['hwsurl']);
     }
     $SESSION->{'publicClient' . $repositoryid} = serialize($publicClient);
     return $publicClient;
 }
Ejemplo n.º 26
0
/**
 * Upgrade function.
 *
 * @param int $oldversion the version we are upgrading from.
 * @return bool result
 */
function xmldb_repository_boxnet_upgrade($oldversion)
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    if ($oldversion < 2013110503) {
        // Delete old user preferences containing auth tokens.
        $DB->delete_records('user_preferences', array('name' => 'boxnet__auth_token'));
        upgrade_plugin_savepoint(true, 2013110503, 'repository', 'boxnet');
    }
    if ($oldversion < 2013110700) {
        require_once $CFG->dirroot . '/repository/lib.php';
        require_once $CFG->dirroot . '/repository/boxnet/db/upgradelib.php';
        $clientid = get_config('boxnet', 'clientid');
        $clientsecret = get_config('boxnet', 'clientsecret');
        // Only proceed if the repository hasn't been set for APIv2 yet.
        if ($clientid === false && $clientsecret === false) {
            $params = array();
            $params['context'] = array();
            $params['onlyvisible'] = false;
            $params['type'] = 'boxnet';
            $instances = repository::get_instances($params);
            // Notify the admin about the migration process if they are using the repo.
            if (!empty($instances)) {
                repository_boxnet_admin_upgrade_notification();
            }
            // Hide the repository.
            $repositorytype = repository::get_type_by_typename('boxnet');
            if (!empty($repositorytype)) {
                $repositorytype->update_visibility(false);
            }
        }
        upgrade_plugin_savepoint(true, 2013110700, 'repository', 'boxnet');
    }
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
Ejemplo n.º 27
0
    /**
     * Returns HTML for this form element.
     *
     * @return string
     */
    function toHtml()
    {
        global $PAGE, $OUTPUT;
        $id = $this->_attributes['id'];
        $elname = $this->_attributes['name'];
        if ($this->_hiddenLabel) {
            $this->_generateId();
            $str = '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml();
        } else {
            $str = HTML_QuickForm_Text::toHtml();
        }
        if (empty($this->_options['usefilepicker'])) {
            return $str;
        }
        $client_id = uniqid();
        $args = new stdClass();
        $args->accepted_types = '*';
        $args->return_types = FILE_EXTERNAL;
        $args->context = $PAGE->context;
        $args->client_id = $client_id;
        $args->env = 'url';
        $refrepos = repository::get_instances(array('currentcontext' => $PAGE->context, 'return_types' => FILE_EXTERNAL));
        $disabled = array();
        foreach ($refrepos as $repo) {
            if (($name = $repo->get_typename()) != $this->_options['repo']) {
                $disabled[] = $name;
            }
        }
        $args->disable_types = $disabled;
        $fp = new file_picker($args);
        $options = $fp->options;
        if (count($options->repositories) > 0) {
            $straddlink = get_string('choosealink', 'repository');
            $str .= <<<EOD
<button id="filepicker-button-{$client_id}" class="visibleifjs">
{$straddlink}
</button>
EOD;
        }
        // print out file picker
        $str .= $OUTPUT->render($fp);
        $module = array('name' => 'form_url', 'fullpath' => '/lib/form/url.js', 'requires' => array('core_filepicker'));
        $PAGE->requires->js_init_call('M.form_url.init', array($options), true, $module);
        return $str;
    }
Ejemplo n.º 28
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
     global $SESSION;
     parent::__construct($repositoryid, $context, $options);
     $this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
     if (empty($this->keyword)) {
         $this->keyword = optional_param('s', '', PARAM_RAW);
     }
     $sess_keyword = 'wikimedia_'.$this->id.'_keyword';
     if (empty($this->keyword) && optional_param('page', '', PARAM_RAW)) {
         // This is the request of another page for the last search, retrieve the cached keyword
         if (isset($SESSION->{$sess_keyword})) {
             $this->keyword = $SESSION->{$sess_keyword};
         }
     } else if (!empty($this->keyword)) {
         // save the search keyword in the session so we can retrieve it later
         $SESSION->{$sess_keyword} = $this->keyword;
     }
 }
Ejemplo n.º 29
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     // set up owncloud client
     if (empty($this->options['owncloud_server'])) {
         return;
     }
     if ($this->options['owncloud_auth'] == 'none') {
         $this->options['owncloud_auth'] = false;
     }
     if (empty($this->options['owncloud_type'])) {
         $this->webdav_type = '';
     } else {
         $this->webdav_type = 'ssl://';
     }
     if (empty($this->options['owncloud_port'])) {
         $port = '';
         if (empty($this->webdav_type)) {
             $this->webdav_port = 80;
         } else {
             $this->webdav_port = 443;
             $port = ':443';
         }
     } else {
         $this->webdav_port = $this->options['owncloud_port'];
         $port = ':' . $this->webdav_port;
     }
     //$this->username = $this->options['owncloud_username'];
     //$this->password = $this->options['owncloud_password'];
     $this->username = optional_param('owncloud_user', '', PARAM_RAW);
     $this->password = optional_param('owncloud_pass', '', PARAM_RAW);
     $this->options['owncloud_username'] = $this->username;
     $this->options['owncloud_password'] = $this->password;
     $this->webdav_host = $this->webdav_type . $this->options['owncloud_server'] . $port;
     $this->dav = new webdav_client($this->options['owncloud_server'], $this->options['owncloud_username'], $this->options['owncloud_password'], $this->options['owncloud_auth'], $this->webdav_type);
     $this->dav->port = $this->webdav_port;
     $this->dav->debug = false;
 }
Ejemplo n.º 30
0
    /**
     * Installing repository tests
     *
     * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
     */
    public function test_install_repository() {
        global $CFG, $DB;

        $this->resetAfterTest(true);

        $syscontext = context_system::instance();
        $repositorypluginname = 'boxnet';
        // override repository permission
        $capability = 'repository/' . $repositorypluginname . ':view';
        $allroles = $DB->get_records_menu('role', array(), 'id', 'archetype, id');
        assign_capability($capability, CAP_ALLOW, $allroles['guest'], $syscontext->id, true);

        $plugintype = new repository_type($repositorypluginname);
        $pluginid = $plugintype->create(false);
        $this->assertInternalType('int', $pluginid);
        $args = array();
        $args['type'] = $repositorypluginname;
        $repos = repository::get_instances($args);
        $repository = reset($repos);
        $this->assertInstanceOf('repository', $repository);
        $info = $repository->get_meta();
        $this->assertEquals($repositorypluginname, $info->type);
    }