function wp_new_user_notification($user_id, $plaintext_pass = '')
    {
        //pyboxlog('called wp_n_u_n', 1);
        $user = new WP_User($user_id);
        $body = __t('An account has been created for you on the Computer Science Circles website, with a randomly generated password.

User name: %username%
Current random password: %password%

Please visit
%loginurl%
and change your password to something you will remember. 
Press "%upprof%" once you are done.

Thanks from the Computer Science Circles team!
%siteurl%');
        //pyboxlog('locale:' . pll_current_language('locale'), 1);
        if (class_exists('PLL_Base')) {
            update_user_meta($user_id, 'user_lang', pll_current_language('locale'));
        }
        $subject = __t('Computer Science Circles: New account');
        $user_login = stripslashes($user->user_login);
        $user_email = stripslashes($user->user_email);
        $find = array('/%username%/i', '/%password%/i', '/%blogname%/i', '/%siteurl%/i', '/%loginurl%/i', '/%useremail%/i', '/%upprof%/i');
        $replace = array($user_login, $plaintext_pass, get_option('blogname'), get_option('siteurl'), get_option('siteurl') . '/wp-login.php', $user_email, __t('Update Profile'));
        $body = preg_replace($find, $replace, $body);
        $body = preg_replace("/%.*%/", "", $body);
        pb_mail('"' . get_option('blogname') . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>', '<' . $user_email . '>', $subject, $body);
    }
 function _addOption()
 {
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     $option = $this->data['FieldOption']['text'] = Sanitize::getString($this->data, 'text');
     $value = $this->data['FieldOption']['value'] = Sanitize::stripAll($this->data, 'text');
     $fieldid = $this->data['FieldOption']['fieldid'] = Sanitize::getInt($this->data, 'field_id');
     $fieldName = Sanitize::getString($this->data, 'name');
     // Begin validation
     if ($value == '') {
         $validation = __t("The field is empty.", true);
         $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\">&nbsp;" . $validation . "</span>');";
         return $this->ajaxResponse($response);
     }
     // Save
     $result = $this->FieldOption->save($this->data);
     switch ($result) {
         case 'success':
             // Begin update display
             $option = $this->data['FieldOption']['text'];
             $value = $this->data['FieldOption']['value'];
             $response = "\n                        jQuery('#{$fieldName}').addOption('{$value}','" . addslashes($option) . "');\n                        jQuery('#jr_fieldOption{$fieldid}').val('');            \n                        jQuery('#submitButton{$fieldid}').removeAttr('disabled');\n                    ";
             return $this->ajaxResponse($response);
         case 'duplicate':
             $validation = sprintf(__t("%s already exists", true), $value);
             break;
         case 'db_error':
             $validation = s2Messages::submitErrorGeneric();
             break;
     }
     $response[] = "jQuery('#{$fieldName}').selectOptions('" . addslashes($option) . "');";
     $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\">&nbsp;" . $validation . "</span>');";
     return $this->ajaxResponse($response);
 }
 public function logoutAction($key = 'user')
 {
     Session::remove($key);
     Session::destroy();
     Session::setFlash(__t('you_logout'));
     $this->redirect("/");
 }
 function __construct()
 {
     parent::__construct();
     switch ($this->integrationMode) {
         case 'groups':
             // The primary key for categories
             switch (getCmsVersion()) {
                 case CMS_JOOMLA10:
                 case CMS_MAMBO46:
                     $this->categoryPrimaryKey = 'group_id';
                     break;
                 case CMS_JOOMLA15:
                     $this->categoryPrimaryKey = 'id';
                     break;
             }
             $this->joins = array('Total' => "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_comprofiler'", "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id', 'LEFT JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__users AS User ON User.id = Listing.id");
             $this->joinsReviews = array("LEFT JOIN #__users AS Listing ON Review.pid = Listing.id", "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             break;
         case 'fields':
             $this->fields = array('Listing.id AS `Listing.listing_id`', 'Listing.username AS `Listing.title`', 'CommunityBuilder.avatar AS `Listing.images`', 'CommunityBuilder.avatarapproved AS `Listing.images_approved`', "'com_comprofiler' AS `Listing.extension`", 'JreviewsCategory.id AS `Listing.cat_id`', 'Category.fieldtitle AS `Category.title`', 'JreviewsCategory.id AS `Category.cat_id`', 'Criteria.id AS `Criteria.criteria_id`', 'Criteria.criteria AS `Criteria.criteria`', 'Criteria.tooltips AS `Criteria.tooltips`', 'Criteria.weights AS `Criteria.weights`', 'Criteria.required AS `Criteria.required`', 'Criteria.state AS `Criteria.state`');
             $this->joins = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->cbCustomField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             $this->joinsReviews = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Review.pid = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->cbCustomField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             break;
     }
     $this->tag = __t("COMMUNITY_BUILDER_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
 }
 function __construct()
 {
     parent::__construct();
     $cms_version = getCmsVersion();
     switch ($this->integrationMode) {
         case 'groups':
             $this->fields['Category.title'] = 'Category.title AS `Category.title`';
             $this->joins = array('Total' => "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_comprofiler'", 'CategoryMap' => "LEFT JOIN #__user_usergroup_map AS CategoryMap ON Listing.id = CategoryMap.user_id", 'JreviewsCategory' => "INNER JOIN #__jreviews_categories AS JreviewsCategory ON CategoryMap.group_id = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'Category' => "LEFT JOIN #__usergroups AS Category ON CategoryMap.group_id = Category.{$this->categoryPrimaryKey}", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id', 'LEFT JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__users AS User ON User.id = Listing.id");
             $this->group[] = 'Listing.id';
             $this->joinsReviews = array("LEFT JOIN #__users AS Listing ON Review.pid = Listing.id", 'CategoryMap' => "LEFT JOIN #__user_usergroup_map AS CategoryMap ON Listing.id = CategoryMap.user_id", 'JreviewsCategory' => "INNER JOIN #__jreviews_categories AS JreviewsCategory ON CategoryMap.group_id = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'Category' => "LEFT JOIN #__usergroups AS Category ON CategoryMap.group_id = Category.{$this->categoryPrimaryKey}", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             if ($cms_version == CMS_JOOMLA15) {
                 unset($this->group);
                 $this->fields['Category.title'] = 'Category.name AS `Category.title`';
                 $this->joins = array('Total' => "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = 'com_comprofiler'", 'Category' => "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", 'JreviewsCategory' => "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id', 'LEFT JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__users AS User ON User.id = Listing.id");
                 $this->joinsReviews = array("LEFT JOIN #__users AS Listing ON Review.pid = Listing.id", "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             }
             break;
         case 'fields':
             $this->fields = array('Listing.id AS `Listing.listing_id`', 'Listing.title' => 'Listing.username AS `Listing.title`', 'CommunityBuilder.avatar AS `Listing.images`', 'CommunityBuilder.avatarapproved AS `Listing.images_approved`', "'com_comprofiler' AS `Listing.extension`", 'JreviewsCategory.id AS `Listing.cat_id`', 'Category.fieldtitle AS `Category.title`', 'JreviewsCategory.id AS `Category.cat_id`', 'Criteria.id AS `Criteria.criteria_id`', 'Criteria.criteria AS `Criteria.criteria`', 'Criteria.tooltips AS `Criteria.tooltips`', 'Criteria.weights AS `Criteria.weights`', 'Criteria.required AS `Criteria.required`', 'Criteria.state AS `Criteria.state`');
             $this->joins = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->cbCustomField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             $this->joinsReviews = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Review.pid = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->cbCustomField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
             break;
     }
     $this->tag = __t("COMMUNITY_BUILDER_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
     # Use name or username based on JReviews config
     $Config = Configure::read('JreviewsSystem.Config');
     if ($Config->name_choice == 'realname') {
         $this->fields['Listing.title'] = 'Listing.name AS `Listing.title`';
     }
     unset($Config);
 }
Beispiel #6
0
 /**
  * Generate a "random" alpha-numeric string.
  *
  * From Laravel
  * @param  int $length
  * @return string
  */
 public static function random($length = 16)
 {
     $length = (int) $length;
     if ($length <= 0) {
         throw new \InvalidArgumentException(__t('random_length_must_be_greater_then_zero'));
     }
     if (function_exists('random_bytes')) {
         try {
             $random = random_bytes($length);
         } catch (\Exception $e) {
             $random = static::randomString($length);
         }
     } else {
         if (function_exists('openssl_random_pseudo_bytes')) {
             $string = '';
             while (($len = strlen($string)) < $length) {
                 $size = $length - $len;
                 $bytes = openssl_random_pseudo_bytes($size);
                 $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
             }
             $random = $string;
         } else {
             $random = static::randomString($length);
         }
     }
     return $random;
 }
Beispiel #7
0
 /**
  * Pass a closure to this function in order to modify the output data
  * before it is json_encoded and sent to the client. The callable should
  * accept an array parameter, and return the modified array.
  * @param  callable $callable
  * @return null
  */
 public static function preDispatch($callable)
 {
     if (!is_callable($callable)) {
         throw new \InvalidArgumentException(__t('predispatch_callable_must_be_callable'));
     }
     self::$preDispatch = $callable;
 }
function dbProblemHistory($limit, $sortname, $sortorder, $req = NULL)
{
    global $db_query_info;
    $db_query_info = array();
    if ($req == NULL) {
        $req = $_REQUEST;
    }
    $db_query_info['type'] = 'problem-history';
    $problemname = getSoft($req, "p", "");
    //which problem?
    $user = getSoft($req, "user", "");
    if ($problemname == "") {
        return __t("You must enter a non-empty problem name.");
    }
    $db_query_info['problem'] = $problemname;
    $resultdesc = array('y' => __t('Did not crash.'), 'Y' => __t('Correct!'), 'N' => __t('Incorrect.'), 'E' => __t('Internal error.'), 'S' => __t('Saved.'), 's' => __t('Saved.'));
    if (!is_user_logged_in()) {
        return __t("You must log in to view past submissions.");
    }
    if ((userIsAdmin() || userIsAssistant()) && $user != "") {
        $u = get_userdata($user);
        if ($u === false) {
            return sprintf(__t("User number %s not found."), $u);
        }
        $db_query_info['viewuser'] = $user;
    } else {
        $u = wp_get_current_user();
    }
    $uid = $u->ID;
    $uname = $u->user_login;
    global $wpdb;
    $table_name = $wpdb->prefix . "pb_submissions";
    $counts = $wpdb->get_results($wpdb->prepare("SELECT COUNT(1), COUNT(userinput) from {$table_name}\nWHERE userid = %d AND problem = %s", $uid, $problemname), ARRAY_N);
    $count = $counts[0][0];
    $showInputColumn = $counts[0][1] > 0;
    if ($count == 0) {
        return sprintf(__t('We do not have record of any submissions from user %1$s for problem %2$s.'), $uname . ' (#' . $uid . ')', $problemname);
    }
    $knownFields = array(__t("time &amp; ID") => "beginstamp", __t("user code") => "usercode", __t("user input") => "userinput", __t("result") => "result");
    if (array_key_exists($sortname, $knownFields)) {
        $sortString = $knownFields[$sortname] . " " . $sortorder . ", ";
    } else {
        $sortString = "";
    }
    $prep = $wpdb->prepare("SELECT ID, beginstamp, usercode, userinput, result from {$table_name}\nWHERE userid = %d AND problem = %s ORDER BY {$sortString} ID DESC" . $limit, $uid, $problemname);
    $flexirows = array();
    foreach ($wpdb->get_results($prep, ARRAY_A) as $r) {
        $cell = array();
        $cell[__t('user code')] = preBox($r['usercode'], -1, -1);
        if ($showInputColumn) {
            $cell[__t('user input')] = $r['userinput'] === NULL ? '<i>' . __t('n/a') . '</i>' : preBox($r['userinput'], -1, 100000);
        }
        if ($problemname != "visualizer") {
            $cell[__t('result')] = getSoft($resultdesc, $r['result'], $r['result']);
        }
        $cell[__t('time &amp; ID')] = str_replace(' ', '<br/>', $r['beginstamp']) . '<br/>#' . $r['ID'];
        $flexirows[] = array('id' => $r['ID'], 'cell' => $cell);
    }
    return array('total' => $count, 'rows' => $flexirows);
}
 /**
  * Fetch Video information
  * @param $videoID
  * @return array
  */
 protected function fetchInfo($videoID)
 {
     $info = [];
     $info['title'] = __t('unable_to_retrieve_x_title', ['service' => 'Vimeo']);
     $info['size'] = 0;
     $info['width'] = 560;
     $info['height'] = 540;
     // Get Data
     $url = 'http://vimeo.com/api/v2/video/' . $videoID . '.json';
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
     $content = curl_exec($ch);
     curl_close($ch);
     $array = json_decode($content, true);
     if (!$array) {
         return $info;
     }
     $result = $array[0];
     $info['title'] = $result['title'];
     $info['caption'] = strip_tags($result['description']);
     $info['size'] = $result['duration'];
     $info['height'] = $result['height'];
     $info['width'] = $result['width'];
     $info['tags'] = $result['tags'];
     $info['data'] = $this->getThumbnail($result['thumbnail_large']);
     return $info;
 }
 /**
  * Parse an embed ID
  * @param $embedID
  * @return array
  */
 public function parseID($embedID)
 {
     $defaultInfo = ['embed_id' => $embedID, 'title' => __t('x_type_x', ['service' => $this->getName(), 'type' => $this->getProviderType()]) . ': ' . $embedID, 'size' => 0, 'name' => $this->getName() . '_' . $embedID . '.jpg', 'type' => $this->getType()];
     $info = array_merge($defaultInfo, $this->fetchInfo($embedID));
     $info['html'] = $this->getCode($info);
     return $info;
 }
 function findChildOptions()
 {
     $response = array();
     $childField = Sanitize::getString($this->data, 'childField');
     $childSelected = Sanitize::getString($this->data, 'childSelected');
     $parentValue = Sanitize::getString($this->data, 'parentValue');
     $module_id = Sanitize::getInt($this->data, 'module_id');
     if ($parentValue == '') {
         $ret = '<option value="">' . __t("Select", true, true) . '</option>';
         $response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').attr('disabled','disabled');";
         return implode(' ', $response);
     }
     $query = "                                                                                           \r\n            SELECT \r\n                FieldOption.optionid, FieldOption.text, FieldOption.value\r\n            FROM #__jreviews_fieldoptions AS FieldOption\r\n            INNER JOIN #__jreviews_fields AS Field ON FieldOption.fieldid = Field.fieldid AND Field.name = '" . $childField . "'\r\n            WHERE FieldOption.value LIKE '" . $parentValue . "-%'\r\n        ";
     $this->_db->setQuery($query);
     $options = $this->_db->loadAssocList();
     $ret = '<option value="">' . __t("Select", true, true) . '</option>';
     foreach ($options as $option) {
         if ($childSelected != '' && $option['value'] == $childSelected) {
             $ret .= '<option selected="selected" value="' . $option['value'] . '">' . $option['text'] . '</option>';
         } else {
             $ret .= '<option value="' . $option['value'] . '">' . $option['text'] . '</option>';
         }
     }
     $response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').removeAttr('disabled');";
     return implode(' ', $response);
 }
 function __construct()
 {
     parent::__construct();
     $this->tag = __t("K2_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     //		$this->fields[] = "'{$this->tag }' AS `Listing.tag`";
 }
Beispiel #13
0
 public static function send($viewPath, $data, $callback)
 {
     $config = Bootstrap::get('config');
     $mailer = Bootstrap::get('mailer');
     if (!$mailer) {
         throw new InvalidArgumentException(__t('mail_configuration_no_defined'));
     }
     $DirectusSettingsTableGateway = new \Zend\Db\TableGateway\TableGateway('directus_settings', Bootstrap::get('zendDb'));
     $rowSet = $DirectusSettingsTableGateway->select();
     $settings = [];
     foreach ($rowSet as $setting) {
         $settings[$setting['collection']][$setting['name']] = $setting['value'];
     }
     $instance = new static($mailer, $settings);
     $message = Swift_Message::newInstance();
     // default mail from address
     $mailConfig = $config['mail'];
     $message->setFrom($mailConfig['from']);
     call_user_func($callback, $message);
     if ($message->getBody() == null) {
         // Slim Extras View twig act weird on this version
         $viewContent = $instance->getViewContent($viewPath, $data);
         $message->setBody($viewContent, 'text/html');
     }
     $instance->sendMessage($message);
 }
Beispiel #14
0
 public function validate($data)
 {
     parent::validate($data);
     $step = install_get_step(3);
     if ($this->isStrictMode($step)) {
         throw new \RuntimeException(__t('mysql_strict_mode_warning'));
     }
 }
 function __construct()
 {
     parent::__construct();
     // Used in MyReviews page to differentiate from other component reviews
     $this->tag = __t("EZREALTY_PROFILE_TAG", true);
     // Uncomment line below to show tag in My Reviews page
     //		$this->fields[] = "'{$this->tag }' AS `Listing.tag`";
 }
Beispiel #16
0
 function __construct()
 {
     parent::__construct();
     $this->tag = __t("SOBI2_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
     // Comment this line to hide the tag from the output
 }
Beispiel #17
0
 public function runCommand($command, $args, $extra)
 {
     $cmd_name = 'cmd' . ucwords($command);
     if (!method_exists($this, $cmd_name)) {
         throw new UnsupportedCommandException($this->__module_name . ':' . $command . __t(' command does not exists!'));
     }
     $this->{$cmd_name}($args, $extra);
 }
 function __construct()
 {
     parent::__construct();
     $this->joins = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Listing.id = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->customField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
     $this->joinsReviews = array('INNER JOIN #__comprofiler AS CommunityBuilder ON Review.pid = CommunityBuilder.id', "LEFT JOIN #__comprofiler_field_values AS Category ON CommunityBuilder.{$this->customField} = Category.fieldtitle", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Category.fieldvalueid = JreviewsCategory.id AND JreviewsCategory.`option` = 'com_comprofiler'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
     $this->tag = __t("COMMUNITY_BUILDER_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
 }
 public function admin_index()
 {
     $options = array('contain' => array('CmsImage', 'CmsTag'), 'conditions' => $this->postConditions($this->_getPassedDefaults()), 'paginate' => array('limit' => 50));
     if (!empty($this->params['named']['tag'])) {
         $tagId = $this->params['named']['tag'];
         $this->set('title', __t('Node tagged as "{$tag}"', array('tag' => $this->CmsNode->CmsTag->field('CmsTag.name', array('CmsTag.id' => $tagId)))));
         $options = array('link' => array('CmsImage' => array('conditions' => 'CmsImage.id = CmsNode.cms_image_id'), 'CmsNodesCmsTags' => array('TagFilter' => array('class' => 'CmsTag', 'conditions' => 'TagFilter.id = CmsNodesCmsTags.cms_tag_id', 'fields' => array('TagFilter.id')))), 'contain' => array('CmsTag'), 'conditions' => array('TagFilter.id' => $tagId));
     }
     $this->_admin_index($options);
 }
 function __construct()
 {
     parent::__construct();
     // Used in MyReviews page to differentiate from other component reviews
     $this->tag = __t("MYBLOG_TAG", true);
     // Uncomment line below to show tag in My Reviews page
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
     // Set default WHERE statement
     $this->conditions = array('Listing.state = 1', '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )', '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )', 'Listing.access <= ' . $this->_user->gid, 'Listing.catid > 0');
 }
Beispiel #21
0
 function screenName(&$entry, $link = true)
 {
     // $Config param not being used
     $screenName = $this->Config->name_choice == 'realname' ? $entry['User']['name'] : $entry['User']['username'];
     if ($link && !empty($entry['Community']) && $entry['User']['user_id'] > 0) {
         return $this->profileLink($screenName, $entry['Community']['community_user_id'], $entry['Community']['menu_id']);
     }
     $screenName = $screenName == '' ? __t("Guest", true) : $screenName;
     return $screenName;
 }
 /**
  * Create a config and configuration file into $path
  * @param $data
  * @param $path
  */
 public static function createConfig($data, $path)
 {
     $requiredAttributes = ['db_host', 'db_name', 'db_user', 'db_password', 'directus_path'];
     if (!ArrayUtils::contains($data, $requiredAttributes)) {
         $message = sprintf(__t('creating_config_files_required_x', ['attributes' => implode(', ', $requiredAttributes)]));
         throw new \InvalidArgumentException($message);
     }
     static::createConfigFile($data, $path);
     static::createConfigurationFile($data, $path);
 }
function dbProblemSummary($limit, $sortname, $sortorder, $req = NULL)
{
    global $db_query_info;
    $db_query_info = array();
    if ($req == NULL) {
        $req = $_REQUEST;
    }
    $db_query_info['type'] = 'problem-summary';
    if (!is_user_logged_in()) {
        return __t("You must log in to view past submissions.");
    }
    $problemslug = getSoft($req, "p", "");
    //which problem?
    if ($problemslug == "") {
        return __t("You must enter a non-empty problem name.");
    }
    global $wpdb;
    $problem_table = $wpdb->prefix . "pb_problems";
    $problemname = $wpdb->get_var($wpdb->prepare("SELECT publicname FROM {$problem_table} WHERE lang = '%s' AND slug = '%s'", pll_current_language(), $problemslug));
    if ($problemname == null) {
        return sprintf(__t("Problem %s not found (at least in current language)"), $problemslug);
    }
    $db_query_info['problem'] = $problemslug;
    $u = wp_get_current_user();
    $uid = $u->ID;
    $db_query_info['viewuser'] = $uid;
    $ulogin = $u->user_login;
    $submit_table = $wpdb->prefix . "pb_submissions";
    $usermeta_table = $wpdb->prefix . "usermeta";
    $user_table = $wpdb->prefix . "users";
    $complete_table = $wpdb->prefix . "pb_completed";
    $count = $wpdb->get_var(userIsAdmin() ? "SELECT count(1) FROM {$user_table}" : $wpdb->prepare("SELECT count(1) FROM {$usermeta_table} WHERE meta_key=%s AND meta_value=%s", 'pbguru', $ulogin));
    $students = $wpdb->get_results(userIsAdmin() ? "SELECT ID FROM {$user_table} {$limit}" : $wpdb->prepare("SELECT user_id AS ID FROM {$usermeta_table} WHERE meta_key=%s AND meta_value=%s {$limit}", 'pbguru', $ulogin));
    // no sorting allowed due to weird nature of query
    $flexirows = array();
    foreach ($students as $r) {
        $sid = $r->ID;
        $sdata = $wpdb->get_row($wpdb->prepare("SELECT usercode, beginstamp FROM {$submit_table} \n                        WHERE userid={$sid} and problem='%s' and result='Y'\n                        ORDER BY beginstamp DESC limit 1", $problemslug));
        $s = get_userdata($sid);
        $cell = array();
        $cell['ID'] = $sid;
        $cell['info'] = userString($sid);
        if ($sdata != null) {
            $cell[__t('latest correct')] = prebox($sdata->usercode);
            $cell[__t('last time')] = $sdata->beginstamp;
            $cell[__t('first time')] = $wpdb->get_var($wpdb->prepare("SELECT time FROM {$complete_table} WHERE userid={$sid} and problem='%s'", $problemslug));
        } else {
            $cell[__t('latest correct')] = '<i>n/a</i>';
            $cell[__t('last time')] = '<i>n/a</i>';
            $cell[__t('first time')] = '<i>n/a</i>';
        }
        $flexirows[] = array('id' => $sid, 'cell' => $cell);
    }
    return array('total' => $count, 'rows' => $flexirows);
}
Beispiel #24
0
 function validateImages()
 {
     if (isset($_FILES)) {
         $supportedTypes = array('image/gif', 'image/jpeg', 'image/png', 'image/pjpeg', 'image/x-png');
         $max_file_size = $this->Config->content_max_imgsize;
         // in Kbytes
         $msgTags = array();
         $err = 0;
         $fileKeys = array();
         if (isset($_FILES['image']['error'])) {
             foreach ($_FILES['image']['error'] as $key => $error) {
                 $tmp_name = $_FILES['image']['tmp_name'][$key];
                 $name = basename($_FILES['image']['name'][$key]);
                 $size = $_FILES['image']['size'][$key];
                 $type = $_FILES['image']['type'][$key];
                 if ($name != '') {
                     //ignore if field left empty
                     if ($error == UPLOAD_ERR_OK && is_uploaded_file($tmp_name)) {
                         $err = 0;
                         // File size check
                         if ($size / 1024 > $max_file_size) {
                             $msgTags['file_size']['err'][] = $name . ' ' . sprintf(__t("is %s Kb.", true), number_format($size / 1024, 0));
                             $msgTags['file_size']['label'] = __t("Some files exceed the allowed size, please correct this and resubmit the form:", true, true);
                             $err = 1;
                         }
                         // File type check
                         $image_info = getimagesize($_FILES['image']['tmp_name'][$key]);
                         // Checks if file is an actual image
                         $mimeType = isset($image_info['mime']) ? $image_info['mime'] : null;
                         if (!$image_info || !in_array($mimeType, $supportedTypes)) {
                             $msgTags['file_type']['err'][] = sprintf(__t("%s is not a supported image file.", true, true), $name);
                             $msgTags['file_type']['label'] = __t("Some files are not images, please correct this and resubmit the form:", true, true);
                             $err = 1;
                         }
                         if (!$err) {
                             $fileKeys[] = $key;
                         }
                     } else {
                         $this->attack = __t("Could not upload file.", true, true);
                     }
                 }
                 // end if ($name!='')
             }
             // end foreach
         }
         if (!empty($fileKeys) && !$this->attack) {
             $this->success = true;
         } else {
             $this->success = false;
         }
         $this->fileKeys = $fileKeys;
         $this->msgTags = $msgTags;
     }
     // end if isset
 }
Beispiel #25
0
 function round($value, $scale)
 {
     if (is_numeric($value)) {
         $value = ceil($value * 100) / 100;
         // extra math forces ceil() to work with decimals
         $round = $scale > 10 ? 0 : 1;
         return number_format($value, $round);
     } else {
         return empty($value) ? '0.0' : '<span class="jr_noRating" title="' . __t('Not rated', true) . '">' . __t('N/A', true) . '</span>';
     }
 }
Beispiel #26
0
 /**
  * Convenience method to display a 403 page.
  *
  * @param array $params Parameters for controller
  * @access public
  */
 function error403($params)
 {
     extract($params, EXTR_OVERWRITE);
     if (!isset($url)) {
         $url = $this->controller->here;
     }
     $url = Router::normalize($url);
     $this->controller->header("HTTP/1.0 403 Forbidden");
     $this->controller->set(array('title_for_layout' => __t('Forbidden'), 'title' => __t('403 Forbidden'), 'url' => h($url)));
     $this->_outputMessage('error403');
 }
 public function totalListAction()
 {
     if (Session::hasUser('admin')) {
         $menuModel = new MenuModel();
         $menu_data = array();
         foreach (Config::get('languages') as $v) {
             foreach ($menuModel->getMainMenu($v) as $val) {
                 $t = $val['id_page'];
                 $menu_data[$v][$t] = $val;
             }
         }
         //  Debugger::PrintR($menu_data);
         $adminModel = new AdminModel();
         $data_admin = $adminModel->getAdminPage(Router::getId());
         $indexModel = new IndexModel();
         $material_type = $this->totalListMaterialType();
         $data_materials = $indexModel->getTotalList($material_type);
         foreach ($data_materials as $k => $v) {
             if ($v['status'] == 1) {
                 $v['status'] = __t('yes');
             } else {
                 $v['status'] = __t('no');
             }
             $data_materials[$k] = $v;
         }
         $items_count = $indexModel->getCount($material_type);
         $items_per_page = Config::get('materials_per_page');
         $request = new Request();
         $currentPage = $request->get('page') ? (int) $request->get('page') : 1;
         $data_pagination = self::getPagination($items_count, $items_per_page, $currentPage);
         if ($items_count) {
             $data_materials_page = array_chunk($data_materials, $items_per_page, true);
             if (isset($data_materials_page[$currentPage - 1])) {
                 $data_materials_page = $data_materials_page[$currentPage - 1];
             } else {
                 throw new Exception('Page (' . Router::getUri() . ') not found', 404);
             }
         } else {
             $data_materials_page = null;
         }
         $data_url = explode('?', Router::getUri());
         $type_of_materials = array();
         foreach ($indexModel->getType_of_Materials() as $v) {
             $type_of_materials[] = strtolower($v['type_name']);
         }
         $system_doc = array('404' => Config::get('default_id_error_404'), '403' => Config::get('default_id_error_403'), '204' => Config::get('default_id_error_204'), '500' => Config::get('default_id_error_500'), 'default_page' => Config::get('default_id'), 'not_publish' => Config::get('not_publish'), 'contacts' => Config::get('contacts'), 'news' => Config::get('news'), 'search' => Config::get('search'));
         $system_doc_rev = array_flip($system_doc);
         $args = array('data_admin' => $data_admin[0], 'data_materials' => $data_materials_page, 'data_pagination' => $data_pagination, 'data_url' => $data_url[0], 'type_of_materials' => $type_of_materials, 'system_doc' => $system_doc_rev, 'menu_data' => $menu_data, 'items_per_page' => $items_per_page);
         return $this->render_admin($args);
     } else {
         throw new Exception('Access is forbidden', 403);
     }
 }
function showPrevNext()
{
    global $wpdb, $post;
    $table_name = $wpdb->prefix . "pb_lessons";
    if (!isset($post)) {
        return '';
    }
    //not in a single page
    $here = $post->ID;
    $thisrow = $wpdb->get_row("SELECT * FROM {$table_name} WHERE id = {$here}");
    if ($thisrow == NULL) {
        return '';
    }
    // not a numbered lesson
    $lo = $thisrow->ordering - 1;
    $hi = $thisrow->ordering + 2;
    $results = $wpdb->get_results("SELECT * FROM {$table_name} WHERE " . "ordering >= {$lo} AND ordering <= {$hi} AND lang = '" . currLang2() . "' " . "ORDER BY ordering ASC");
    echo '<div class="locator">';
    echo '<table class="locator"><tr>';
    //echo '<td style="text-align: center;">Navigation</td>';
    echo '<td class="locator">';
    foreach ($results as $row) {
        if ($row->ordering < $thisrow->ordering) {
            $s = 'l';
        } elseif ($row->ordering > $thisrow->ordering) {
            $s = 'r';
        } else {
            $s = 'c';
        }
        $factor = $row->ordering - $thisrow->ordering;
        if ($factor > 0) {
            $factor = $factor - 1;
        }
        $factor = abs($factor);
        $factor = 100 - 10 * $factor;
        $longname = $row->number . ': ' . $row->title;
        echo '<a style="font-size:' . $factor . '%" ' . 'class="open-same-window locator locator-' . $s . '" ';
        if ($s != 'c') {
            echo ' title="' . $longname . '" href="' . get_page_link($row->id) . '">';
        } else {
            echo ' title="' . $longname . ' ' . __t('(goes to top of current page)') . '" onclick="scrollToTop()">';
        }
        echo "<span class='buttn'>";
        if ($thisrow->ordering == $row->ordering - 1) {
            echo "<span class='nextlesson'>" . __t("Next") . "</span> ";
        }
        echo $longname;
        echo '</span></a>';
    }
    echo '</td>';
    echo '</tr></table></div>';
}
function send($problem_info, $from, $to, $student, $slug, $body, $noreply)
{
    global $wpdb, $current_user, $lang;
    $unanswered = getUserID() == $student ? 1 : 0;
    if (getUserID() != $student) {
        $wpdb->update($wpdb->prefix . 'pb_mail', array('unanswered' => 0), array('unanswered' => 1, 'ustudent' => $student, 'problem' => $slug));
    }
    if ($noreply != 'false') {
        // don't redirect
        return "#";
    }
    $insert_to = $to;
    if ($to == 0 && $lang != 'en') {
        $insert_to = getSoft(unserialize(CSCIRCLES_ASST_ID_MAP), $lang, $insert_to);
    }
    $wpdb->insert($wpdb->prefix . 'pb_mail', array('ufrom' => $from, 'uto' => $insert_to, 'ustudent' => $student, 'problem' => $slug, 'body' => $body, 'unanswered' => $unanswered), array('%d', '%d', '%d', '%s', '%s', '%d'));
    $mailref = $wpdb->insert_id;
    if (userIsAdmin() || userIsAssistant()) {
        $mFrom = '"' . __t("CS Circles Assistant") . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>';
    } else {
        $mFrom = '"' . $current_user->user_login . '" <' . $current_user->user_email . '>';
    }
    $subject = __t('CS Circles') . ' - ' . __t('message about') . ' ' . $problem_info['publicname'];
    $contents = $body . "\n===\n";
    $contents .= __t("To send a reply message, please visit") . "\n";
    $contents .= cscurl('mail') . "?who={$student}&what={$slug}&which={$mailref}#m\n";
    $contents .= __t("Problem URL:") . " " . $problem_info['url'] . "\n";
    $contents .= "[" . __t("Sent by CS Circles") . " " . cscurl("homepage") . "]";
    if ($to == 0) {
        // same fallback as admin-options.php
        $to_emailaddr = get_option('cscircles_asst_email', get_userdata(1)->user_email);
        $tmp = getSoft(unserialize(CSCIRCLES_ASST_ID_MAP), $lang, -1);
        if ($lang != 'en' && $tmp != -1) {
            $to_emailaddr = get_user_by('id', $tmp)->user_email;
        }
    } else {
        $to_emailaddr = get_user_by('id', $to)->user_email;
    }
    //pyboxlog($mFrom . " " . $to_emailaddr . " " . $subject . " " . $contents);
    pb_mail($mFrom, $to_emailaddr, $subject, $contents);
    if (get_the_author_meta('pbnocc', getUserID()) != 'true') {
        $to_desc = $to == 0 ? "the CS Circles Assistant" : get_user_by('id', $to)->user_login;
        pb_mail($mFrom, $current_user->user_email, __t("SENT:") . " " . $subject, sprintf(__t("THIS IS A COPY of a message you sent to %s."), $to_desc) . "\n\n" . $contents);
    }
    return $mailref;
}
 function __construct()
 {
     parent::__construct();
     // The primary key for categories
     switch (getCmsVersion()) {
         case CMS_JOOMLA10:
         case CMS_MAMBO46:
             $this->categoryPrimaryKey = 'group_id';
             break;
         case CMS_JOOMLA15:
             $this->categoryPrimaryKey = 'id';
             break;
     }
     $this->joins = array('Total' => "LEFT JOIN #__jreviews_listing_totals AS Totals ON Totals.listing_id = Listing.id AND Totals.extension = '{$this->extension_alias}'", "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = '{$this->extension_alias}'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id', 'LEFT JOIN #__community_users AS Community ON Listing.id = Community.userid', "LEFT JOIN #__users AS User ON User.id = Listing.id");
     $this->joinsReviews = array("LEFT JOIN #__users AS Listing ON Review.pid = Listing.id", "LEFT JOIN #__core_acl_aro_groups AS Category ON Listing.gid = Category.{$this->categoryPrimaryKey}", "INNER JOIN #__jreviews_categories AS JreviewsCategory ON Listing.gid = JreviewsCategory.id AND JreviewsCategory.`option` = '{$this->extension_alias}'", 'LEFT JOIN #__jreviews_criteria AS Criteria ON JreviewsCategory.criteriaid = Criteria.id');
     $this->tag = __t("JOMSOCIAL_TAG", true);
     // Used in MyReviews page to differentiate from other component reviews
     $this->fields[] = "'{$this->tag}' AS `Listing.tag`";
 }