Ejemplo n.º 1
0
 public function getPlans($where = '', $limit = ' LIMIT 3', $full_detail = true)
 {
     $plans = $this->db->query("SELECT\n                    \t\t\t\ta.id AS id,\n                    \t\t\t\ta.id_status AS id_status,\n                    \t\t\t\ta.name AS name,\n                    \t\t\t\ta.monthly AS month,\n                                    a.quarterly AS quarter,\n                                    a.semesterly AS semester,\n                                    a.yearly AS year,\n                                    a.content_id,\n                                    (SELECT c.text_small FROM contents c WHERE c.id = a.content_id) AS text_small\n                    \t\t\tFROM {$this->table} a\n                    \t\t\t{$where}\n                    \t\t\tORDER BY id\n                    \t\t\t{$limit}\n                    \t\t");
     $i = 0;
     foreach ($plans->result_array() as $array) {
         //plans
         $i = $array['id'];
         $result[$i]['id'] = $array['id'];
         $result[$i]['name'] = formatString($array['name']);
         $result[$i]['month'] = numberFormat($array['month'], 2);
         $result[$i]['quarter'] = numberFormat($array['quarter'], 2);
         $result[$i]['semester'] = numberFormat($array['semester'], 2);
         $result[$i]['year'] = numberFormat($array['year'], 2);
         $result[$i]['text_small'] = $array['text_small'];
         $result[$i]['content_id'] = $array['content_id'];
         $details = $this->db->query('SELECT description
                         				FROM ' . $this->table . "_details\n                            \t\t\t\tWHERE id_plan = '" . $array['id'] . "'\n                            \t\t\t\tORDER BY id\n                            \t\t\t\t" . ($full_detail ? '' : ' LIMIT 3') . '
                         			');
         $j = 0;
         foreach ($details->result_array() as $detail) {
             //details
             $result[$i]['details'][$j++] = formatString($detail['description']);
         }
         $i++;
     }
     return $result;
 }
Ejemplo n.º 2
0
function formatAddress($row)
{
    //pull together address details into one formatted string
    //$words = preg_split('/[\s,]+/',$var);
    //$num = count($words);
    //for ($i = 0 ; $i < $num ; ++$i)
    //{
    //all alphabetic characters stored in uppercase
    //$words[$i] = strtoupper($words[$i]);
    //}
    //$var = implode(" +",$words);
    //$var = "+" . $var;
    $addressString = '';
    //SAON
    $strTemp = $row[SAON];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    //PAON
    $strTemp = $row[PAON];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    //Street
    $strTemp = $row[Street];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    //Locality
    $strTemp = $row[Locality];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    //District
    $strTemp = $row[District];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    //County
    $strTemp = $row[County];
    $strTemp = $strTemp . trim();
    if (!empty($strTemp)) {
        $strTemp = formatString($strTemp);
        $addressString = $addressString . $strTemp . ",";
    }
    $addressString = $addressString . $row[Postcode1] . " " . $row[Postcode2];
    return $addressString;
}
Ejemplo n.º 3
0
    /**
     * Adds a "My Forums" menu option to the dashboard area.
     */
    public function settingsController_render_before($Sender)
    {
        // Have they visited their dashboard?
        if (strtolower($Sender->RequestMethod) != 'index') {
            $this->saveStep('Plugins.GettingStarted.Dashboard');
        }
        // Save the action if editing registration settings
        if (strcasecmp($Sender->RequestMethod, 'registration') == 0 && $Sender->Form->authenticatedPostBack() === true) {
            $this->saveStep('Plugins.GettingStarted.Registration');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'plugins') == 0) {
            $this->saveStep('Plugins.GettingStarted.Plugins');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'managecategories') == 0) {
            $this->saveStep('Plugins.GettingStarted.Categories');
        }
        // Add messages & their css on dashboard
        if (strcasecmp($Sender->RequestMethod, 'index') == 0) {
            $Sender->addCssFile('getting-started.css', 'plugins/GettingStarted');
            $Session = Gdn::session();
            $WelcomeMessage = '<div class="GettingStarted">' . anchor('&times;', '/dashboard/plugin/dismissgettingstarted/' . $Session->transientKey(), 'Dismiss') . "<h1>" . t("Here's how to get started:") . "</h1>" . '<ul>
        <li class="One' . (c('Plugins.GettingStarted.Dashboard', '0') == '1' ? ' Done' : '') . '">
	    <strong>' . anchor(t('Welcome to your Dashboard'), 'settings') . '</strong>
        <p>' . t('This is the administrative dashboard for your new community.', 'This is the administrative dashboard for your new community. Check out the configuration options to the side. From there you can configure how your community works. <b>By default, only users in the "Administrator" role can see this part of your community.</b>') . '</p>
        </li>
        <li class="Two' . (c('Plugins.GettingStarted.Discussions', '0') == '1' ? ' Done' : '') . '">
	    <strong>' . anchor(t("Where is your Community Forum?"), '/') . '</strong>
        <p>' . formatString(t('Access your community forum by clicking the "Visit Site" link.', 'Access your community forum by clicking the "Visit Site" link at the top of this page, or by <a href={/,url}>clicking here</a>. The community forum is what all of your users &amp; customers will see when they visit <a href="{/,url,domain}">{/,url,domain}</a>.')) . '</p>
        </li>
        <li class="Three' . (c('Plugins.GettingStarted.Categories', '0') == '1' ? ' Done' : '') . '">
        <strong>' . anchor(t('Organize your Categories'), 'vanilla/settings/managecategories') . '</strong>
        <p>' . t('Categories are used to organize discussions.', 'Categories are used to help your users organize their discussions in a way that is meaningful for your community.') . '</p>
        </li>
        <li class="Four' . (c('Plugins.GettingStarted.Profile', '0') == '1' ? ' Done' : '') . '">
        <strong>' . anchor(t('Customize your Public Profile'), 'profile') . '</strong>
        <p>' . formatString(t('Everyone who signs up gets a profile page.', 'Everyone who signs up for your community gets a public profile page where they can upload a picture of themselves, manage their profile settings, and track cool things going on in the community. You should <a href="{/profile,url}">customize your profile now</a>.')) . '</p>
        </li>
        <li class="Five' . (c('Plugins.GettingStarted.Discussion', '0') == '1' ? ' Done' : '') . '">
            <strong>' . anchor(t('Start your First Discussion'), 'post/discussion') . '</strong>
	    <p>' . formatString(t('Start the first discussion.', 'Get the ball rolling in your community by <a href="{/post/discussion,url}">starting the first discussion</a> now.')) . '</p>
        </li>
        <li class="Six' . (c('Plugins.GettingStarted.Plugins', '0') == '1' ? ' Done' : '') . '">
        <strong>' . anchor(t('Manage Plugins'), 'settings/plugins') . '</strong>
        <p>' . t('Change the way your community works with plugins.', 'Change the way your community works with plugins. We\'ve bundled popular plugins with the software, and there are more available online.') . '</p>
      </li>
   </ul>
</div>';
            $Sender->addAsset('Messages', $WelcomeMessage, 'WelcomeMessage');
        }
    }
Ejemplo n.º 4
0
    public function sent()
    {
        $this->load->library('email');
        $body = '
			<table align="center" cellpadding="0" cellspacing="0" border="0" style="width: 600px; font-size: 12px; font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-weight: normal;border: 1px solid #2B7FE9; ">
			<tr>
			<td style="border: 1px solid #2B7FE9;border-bottom: none; background-color: #2B7FE9"><img src="' . base_url() . 'img/top_mail.png" alt=""></td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none; border-top: none;"><h4>Customer Info</h4></td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Name:</strong>&nbsp;' . formatString($this->input->post('txtContactName')) . '</td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Email:</strong>&nbsp;' . $this->input->post('txtContactEmail') . '</td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Phone Number:</strong>&nbsp;' . formatString($this->input->post('txtContactTlf')) . '</td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><h4>Support Info</h4></td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Subject:</strong>&nbsp;' . htmlentities(formatString($this->ModelContents->get_reason($this->input->post('cboContactReason'), 'name'), 2)) . '</td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Message</strong>&nbsp;</td>
			</tr>
			<tr>
			<td style="padding:10px;border: 1px solid #2B7FE9;">' . formatString($this->input->post('txtContactMsg'), 2) . '</td>
			</tr>
			<tr>
			<td>&nbsp;</td>
			</tr>
			</table>
		';
        $ci = get_instance();
        //_imprimir($ci->config->config['head']);
        $this->email->initialize(emailSetting());
        $this->email->from($ci->config->config['head']['no_reply'][1], $ci->config->config['head']['company']);
        $this->email->to('*****@*****.**');
        $this->email->subject(formatString($this->input->post('txtContactName')) . ' wants to cantact you!');
        $this->email->message($body);
        if (!$this->email->send()) {
            $data = ['title' => 'Error', 'message' => 'there was an error when we tried to send the email, try again.', 'debugger' => ''];
        } else {
            $data = ['title' => 'Thanks for your request!', 'message' => 'We have received your message. You will receive a message from us in 24 hours.', 'out' => 'ok', 'url' => $ci->config->config['head']['domain'] . '/content/body/contact-us', 'debugger' => ''];
        }
        echo json_encode($data);
    }
Ejemplo n.º 5
0
 public function lookup($domain)
 {
     $domain = trim(formatString($domain, 3));
     //remove space from start and end of domain
     $aux = explode('.', $domain);
     if (end($aux) == 've') {
         $this->nic_ve($domain);
         $this->tld_domain = $aux[count($aux) - 2] . '.' . array_pop($aux);
         return;
     }
     $domain = empty($aux[1]) ? $domain . '.com' : $domain;
     //if the domain does not have type we put it
     if (substr(strtolower($domain), 0, 7) == 'http://') {
         $domain = substr($domain, 7);
     }
     // remove http:// if included
     if (substr(strtolower($domain), 0, 4) == 'www.') {
         $domain = substr($domain, 4);
     }
     //remove www from domain
     if (preg_match("/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\$/", $domain)) {
         $this->out = $this->queryWhois('whois.lacnic.net', $domain);
     } elseif (preg_match("/^([-a-z0-9]{2,100})\\.([a-z\\.]{2,8})\$/i", $domain)) {
         $domain_parts = explode('.', $domain);
         $this->tld_domain = $tld = strtolower(array_pop($domain_parts));
         $server = $this->servers[$tld][0];
         if (!$server) {
             $this->error_number = 4;
             //echo "Error: No appropriate Whois server found for $domain domain!";
         }
         $this->out = $this->queryWhois($server, $domain);
         while (preg_match_all('/Whois Server: (.*)/', $this->out, $matches)) {
             $server = array_pop($matches[1]);
             $this->out = $this->queryWhois($server, $domain);
         }
         //return $res;
     } else {
         $this->error_number = 2;
         //return "Invalid Input";
     }
     $this->domain = $domain;
     $this->available = preg_match('/No match for/', $this->out, $info) ? 1 : 0;
 }
Ejemplo n.º 6
0
 /**
  *
  *
  * @param $Provider
  * @param array $Options
  * @return string
  */
 public static function connectButton($Provider, $Options = [])
 {
     if (!is_array($Provider)) {
         $Provider = self::getProvider($Provider);
     }
     $Url = htmlspecialchars(self::connectUrl($Provider));
     $Data = $Provider;
     $Target = Gdn::request()->get('Target');
     if (!$Target) {
         $Target = '/' . ltrim(Gdn::request()->path());
     }
     if (stringBeginsWith($Target, '/entry/signin')) {
         $Target = '/';
     }
     $ConnectQuery = ['client_id' => $Provider['AuthenticationKey'], 'Target' => $Target];
     $Data['Target'] = urlencode(url('entry/jsconnect', true) . '?' . http_build_query($ConnectQuery));
     $Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
     $SignInUrl = formatString(val('SignInUrl', $Provider, ''), $Data);
     $RegisterUrl = formatString(val('RegisterUrl', $Provider, ''), $Data);
     if ($RegisterUrl && !val('NoRegister', $Options)) {
         $RegisterLink = ' ' . anchor(sprintf(t('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
     } else {
         $RegisterLink = '';
     }
     if (val('NoConnectLabel', $Options)) {
         $ConnectLabel = '';
     } else {
         $ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(t('Sign In with %s'), $Provider['Name']) . '</div>';
     }
     if (!C('Plugins.JsConnect.NoGuestCheck')) {
         $Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
         if (!val('IsDefault', $Provider)) {
             $Result .= '<div class="JsConnect-Guest">' . anchor(sprintf(t('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
         $Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . img('https://images.v-cdn.net/usericon_50.png', ['class' => 'ProfilePhotoSmall UserPhoto']) . $ConnectLabel . '</a></div>';
         $Result .= '</div>';
     } else {
         if (!val('IsDefault', $Provider)) {
             $Result = '<div class="JsConnect-Guest">' . anchor(sprintf(t('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
     }
     return $Result;
 }
 function listPage()
 {
     $postTile = "";
     $postBlockName = "";
     $sts = "1";
     if (isset($_POST['title'])) {
         $postTile = $_POST["title"];
     }
     if (isset($_POST['sts'])) {
         $sts = $_POST["sts"];
     }
     if (isset($_POST['block_name'])) {
         $postBlockName = $_POST["block_name"];
     }
     $table = "(select a.*,b.block_name,c.usr_nm from content a left join block b on a.block_id=b.block_id left join users c on a.usr_id=c.usr_id where a.sts in (" . formatString($sts) . ") and a.title like '%" . $postTile . "%' and b.block_name like '%" . $postBlockName . "%' order by edit_tm desc) mytable";
     $this->logger = LogUtil::getLogger();
     //$this->logger->info($table);
     $pager = parent::getPager($table, $this->content->db);
     $arrayList = $pager->getData();
     $blockList = $this->block->getBlocks();
     require 'view/admin/content_list.php';
 }
Ejemplo n.º 8
0
 /**
  * Create or update a comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique ID to add the comment to. If blank, this method will throw an error.
  */
 public function comment($DiscussionID = '')
 {
     // Get $DiscussionID from RequestArgs if valid
     if ($DiscussionID == '' && count($this->RequestArgs)) {
         if (is_numeric($this->RequestArgs[0])) {
             $DiscussionID = $this->RequestArgs[0];
         }
     }
     // If invalid $DiscussionID, get from form.
     $this->Form->setModel($this->CommentModel);
     $DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->getFormValue('DiscussionID', 0);
     // Set discussion data
     $this->DiscussionID = $DiscussionID;
     $this->Discussion = $Discussion = $this->DiscussionModel->getID($DiscussionID);
     // Is this an embedded comment being posted to a discussion that doesn't exist yet?
     $vanilla_type = $this->Form->getFormValue('vanilla_type', '');
     $vanilla_url = $this->Form->getFormValue('vanilla_url', '');
     $vanilla_category_id = $this->Form->getFormValue('vanilla_category_id', '');
     $Attributes = array('ForeignUrl' => $vanilla_url);
     $vanilla_identifier = $this->Form->getFormValue('vanilla_identifier', '');
     $isEmbeddedComments = $vanilla_url != '' && $vanilla_identifier != '';
     // Only allow vanilla identifiers of 32 chars or less - md5 if larger
     if (strlen($vanilla_identifier) > 32) {
         $Attributes['vanilla_identifier'] = $vanilla_identifier;
         $vanilla_identifier = md5($vanilla_identifier);
     }
     if (!$Discussion && $isEmbeddedComments) {
         $Discussion = $Discussion = $this->DiscussionModel->getForeignID($vanilla_identifier, $vanilla_type);
         if ($Discussion) {
             $this->DiscussionID = $DiscussionID = $Discussion->DiscussionID;
             $this->Form->setValue('DiscussionID', $DiscussionID);
         }
     }
     // If so, create it!
     if (!$Discussion && $isEmbeddedComments) {
         // Add these values back to the form if they exist!
         $this->Form->addHidden('vanilla_identifier', $vanilla_identifier);
         $this->Form->addHidden('vanilla_type', $vanilla_type);
         $this->Form->addHidden('vanilla_url', $vanilla_url);
         $this->Form->addHidden('vanilla_category_id', $vanilla_category_id);
         $PageInfo = fetchPageInfo($vanilla_url);
         if (!($Title = $this->Form->getFormValue('Name'))) {
             $Title = val('Title', $PageInfo, '');
             if ($Title == '') {
                 $Title = t('Undefined discussion subject.');
                 if (!empty($PageInfo['Exception']) && $PageInfo['Exception'] === "Couldn't connect to host.") {
                     $Title .= ' ' . t('Page timed out.');
                 }
             }
         }
         $Description = val('Description', $PageInfo, '');
         $Images = val('Images', $PageInfo, array());
         $LinkText = t('EmbededDiscussionLinkText', 'Read the full story here');
         if (!$Description && count($Images) == 0) {
             $Body = formatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
         } else {
             $Body = formatString('
         <div class="EmbeddedContent">{Image}<strong>{Title}</strong>
            <p>{Excerpt}</p>
            <p><a href="{Url}">{LinkText}</a></p>
            <div class="ClearFix"></div>
         </div>', array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? img(val(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $vanilla_url, 'LinkText' => $LinkText));
         }
         if ($Body == '') {
             $Body = $vanilla_url;
         }
         if ($Body == '') {
             $Body = t('Undefined discussion body.');
         }
         // Validate the CategoryID for inserting.
         $Category = CategoryModel::categories($vanilla_category_id);
         if (!$Category) {
             $vanilla_category_id = c('Vanilla.Embed.DefaultCategoryID', 0);
             if ($vanilla_category_id <= 0) {
                 // No default category defined, so grab the first non-root category and use that.
                 $vanilla_category_id = $this->DiscussionModel->SQL->select('CategoryID')->from('Category')->where('CategoryID >', 0)->get()->firstRow()->CategoryID;
                 // No categories in the db? default to 0
                 if (!$vanilla_category_id) {
                     $vanilla_category_id = 0;
                 }
             }
         } else {
             $vanilla_category_id = $Category['CategoryID'];
         }
         $EmbedUserID = c('Garden.Embed.UserID');
         if ($EmbedUserID) {
             $EmbedUser = Gdn::userModel()->getID($EmbedUserID);
         }
         if (!$EmbedUserID || !$EmbedUser) {
             $EmbedUserID = Gdn::userModel()->getSystemUserID();
         }
         $EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::toDateTime(), 'DateUpdated' => Gdn_Format::toDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => dbencode($Attributes));
         $this->EventArguments['Discussion'] =& $EmbeddedDiscussionData;
         $this->fireEvent('BeforeEmbedDiscussion');
         $DiscussionID = $this->DiscussionModel->SQL->insert('Discussion', $EmbeddedDiscussionData);
         $ValidationResults = $this->DiscussionModel->validationResults();
         if (count($ValidationResults) == 0 && $DiscussionID > 0) {
             $this->Form->addHidden('DiscussionID', $DiscussionID);
             // Put this in the form so reposts won't cause new discussions.
             $this->Form->setFormValue('DiscussionID', $DiscussionID);
             // Put this in the form values so it is used when saving comments.
             $this->setJson('DiscussionID', $DiscussionID);
             $this->Discussion = $Discussion = $this->DiscussionModel->getID($DiscussionID, DATASET_TYPE_OBJECT, array('Slave' => false));
             // Update the category discussion count
             if ($vanilla_category_id > 0) {
                 $this->DiscussionModel->updateDiscussionCount($vanilla_category_id, $DiscussionID);
             }
         }
     }
     // If no discussion was found, error out
     if (!$Discussion) {
         $this->Form->addError(t('Failed to find discussion for commenting.'));
     }
     /**
      * Special care is taken for embedded comments.  Since we don't currently use an advanced editor for these
      * comments, we may need to apply certain filters and fixes to the data to maintain its intended display
      * with the input format (e.g. maintaining newlines).
      */
     if ($isEmbeddedComments) {
         $inputFormatter = $this->Form->getFormValue('Format', c('Garden.InputFormatter'));
         switch ($inputFormatter) {
             case 'Wysiwyg':
                 $this->Form->setFormValue('Body', nl2br($this->Form->getFormValue('Body')));
                 break;
         }
     }
     $PermissionCategoryID = val('PermissionCategoryID', $Discussion);
     // Setup head
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('autosave.js');
     $this->addJsFile('post.js');
     // Setup comment model, $CommentID, $DraftID
     $Session = Gdn::session();
     $CommentID = isset($this->Comment) && property_exists($this->Comment, 'CommentID') ? $this->Comment->CommentID : '';
     $DraftID = isset($this->Comment) && property_exists($this->Comment, 'DraftID') ? $this->Comment->DraftID : '';
     $this->EventArguments['CommentID'] = $CommentID;
     $this->EventArguments['DraftID'] = $DraftID;
     // Determine whether we are editing
     $Editing = $CommentID > 0 || $DraftID > 0;
     $this->EventArguments['Editing'] = $Editing;
     // If closed, cancel & go to discussion
     if ($Discussion && $Discussion->Closed == 1 && !$Editing && !$Session->checkPermission('Vanilla.Discussions.Close', true, 'Category', $PermissionCategoryID)) {
         redirect(DiscussionUrl($Discussion));
     }
     // Add hidden IDs to form
     $this->Form->addHidden('DiscussionID', $DiscussionID);
     $this->Form->addHidden('CommentID', $CommentID);
     $this->Form->addHidden('DraftID', $DraftID, true);
     // Check permissions
     if ($Discussion && $Editing) {
         // Permission to edit
         if ($this->Comment->InsertUserID != $Session->UserID) {
             $this->permission('Vanilla.Comments.Edit', true, 'Category', $Discussion->PermissionCategoryID);
         }
         // Make sure that content can (still) be edited.
         $EditContentTimeout = c('Garden.EditContentTimeout', -1);
         $CanEdit = $EditContentTimeout == -1 || strtotime($this->Comment->DateInserted) + $EditContentTimeout > time();
         if (!$CanEdit) {
             $this->permission('Vanilla.Comments.Edit', true, 'Category', $Discussion->PermissionCategoryID);
         }
         // Make sure only moderators can edit closed things
         if ($Discussion->Closed) {
             $this->permission('Vanilla.Comments.Edit', true, 'Category', $Discussion->PermissionCategoryID);
         }
         $this->Form->setFormValue('CommentID', $CommentID);
     } elseif ($Discussion) {
         // Permission to add
         $this->permission('Vanilla.Comments.Add', true, 'Category', $Discussion->PermissionCategoryID);
     }
     if ($this->Form->authenticatedPostBack()) {
         // Save as a draft?
         $FormValues = $this->Form->formValues();
         $FormValues = $this->CommentModel->filterForm($FormValues);
         if (!$Editing) {
             unset($FormValues['CommentID']);
         }
         if ($DraftID == 0) {
             $DraftID = $this->Form->getFormValue('DraftID', 0);
         }
         $Type = GetIncomingValue('Type');
         $Draft = $Type == 'Draft';
         $this->EventArguments['Draft'] = $Draft;
         $Preview = $Type == 'Preview';
         if ($Draft) {
             $DraftID = $this->DraftModel->save($FormValues);
             $this->Form->addHidden('DraftID', $DraftID, true);
             $this->Form->setValidationResults($this->DraftModel->validationResults());
         } elseif (!$Preview) {
             // Fix an undefined title if we can.
             if ($this->Form->getFormValue('Name') && val('Name', $Discussion) == t('Undefined discussion subject.')) {
                 $Set = array('Name' => $this->Form->getFormValue('Name'));
                 if (isset($vanilla_url) && $vanilla_url && strpos(val('Body', $Discussion), t('Undefined discussion subject.')) !== false) {
                     $LinkText = t('EmbededDiscussionLinkText', 'Read the full story here');
                     $Set['Body'] = formatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
                 }
                 $this->DiscussionModel->setField(val('DiscussionID', $Discussion), $Set);
             }
             $Inserted = !$CommentID;
             $CommentID = $this->CommentModel->save($FormValues);
             // The comment is now half-saved.
             if (is_numeric($CommentID) && $CommentID > 0) {
                 if (in_array($this->deliveryType(), array(DELIVERY_TYPE_ALL, DELIVERY_TYPE_DATA))) {
                     $this->CommentModel->save2($CommentID, $Inserted, true, true);
                 } else {
                     $this->jsonTarget('', url("/post/comment2.json?commentid={$CommentID}&inserted={$Inserted}"), 'Ajax');
                 }
                 // $Discussion = $this->DiscussionModel->getID($DiscussionID);
                 $Comment = $this->CommentModel->getID($CommentID, DATASET_TYPE_OBJECT, array('Slave' => false));
                 $this->EventArguments['Discussion'] = $Discussion;
                 $this->EventArguments['Comment'] = $Comment;
                 $this->fireEvent('AfterCommentSave');
             } elseif ($CommentID === SPAM || $CommentID === UNAPPROVED) {
                 $this->StatusMessage = t('CommentRequiresApprovalStatus', 'Your comment will appear after it is approved.');
             }
             $this->Form->setValidationResults($this->CommentModel->validationResults());
             if ($CommentID > 0 && $DraftID > 0) {
                 $this->DraftModel->delete($DraftID);
             }
         }
         // Handle non-ajax requests first:
         if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
             if ($this->Form->errorCount() == 0) {
                 // Make sure that this form knows what comment we are editing.
                 if ($CommentID > 0) {
                     $this->Form->addHidden('CommentID', $CommentID);
                 }
                 // If the comment was not a draft
                 if (!$Draft) {
                     // Redirect to the new comment.
                     if ($CommentID > 0) {
                         redirect("discussion/comment/{$CommentID}/#Comment_{$CommentID}");
                     } elseif ($CommentID == SPAM) {
                         $this->setData('DiscussionUrl', DiscussionUrl($Discussion));
                         $this->View = 'Spam';
                     }
                 } elseif ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::date();
                     $this->Comment->Body = val('Body', $FormValues, '');
                     $this->Comment->Format = val('Format', $FormValues, c('Garden.InputFormatter'));
                     $this->addAsset('Content', $this->fetchView('preview'));
                 } else {
                     // If this was a draft save, notify the user about the save
                     $this->informMessage(sprintf(t('Draft saved at %s'), Gdn_Format::date()));
                 }
             }
         } else {
             // Handle ajax-based requests
             if ($this->Form->errorCount() > 0) {
                 // Return the form errors
                 $this->errorMessage($this->Form->errors());
             } else {
                 // Make sure that the ajax request form knows about the newly created comment or draft id
                 $this->setJson('CommentID', $CommentID);
                 $this->setJson('DraftID', $DraftID);
                 if ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::date();
                     $this->Comment->Body = val('Body', $FormValues, '');
                     $this->Comment->Format = val('Format', $FormValues, c('Garden.InputFormatter'));
                     $this->View = 'preview';
                 } elseif (!$Draft) {
                     // If the comment was not a draft
                     // If Editing a comment
                     if ($Editing) {
                         // Just reload the comment in question
                         $this->Offset = 1;
                         $Comments = $this->CommentModel->getIDData($CommentID, array('Slave' => false));
                         $this->setData('Comments', $Comments);
                         $this->setData('Discussion', $Discussion);
                         // Load the discussion
                         $this->ControllerName = 'discussion';
                         $this->View = 'comments';
                         // Also define the discussion url in case this request came from the post screen and needs to be redirected to the discussion
                         $this->setJson('DiscussionUrl', DiscussionUrl($this->Discussion) . '#Comment_' . $CommentID);
                     } else {
                         // If the comment model isn't sorted by DateInserted or CommentID then we can't do any fancy loading of comments.
                         $OrderBy = valr('0.0', $this->CommentModel->orderBy());
                         //                     $Redirect = !in_array($OrderBy, array('c.DateInserted', 'c.CommentID'));
                         //							$DisplayNewCommentOnly = $this->Form->getFormValue('DisplayNewCommentOnly');
                         //                     if (!$Redirect) {
                         //                        // Otherwise load all new comments that the user hasn't seen yet
                         //                        $LastCommentID = $this->Form->getFormValue('LastCommentID');
                         //                        if (!is_numeric($LastCommentID))
                         //                           $LastCommentID = $CommentID - 1; // Failsafe back to this new comment if the lastcommentid was not defined properly
                         //
                         //                        // Don't reload the first comment if this new comment is the first one.
                         //                        $this->Offset = $LastCommentID == 0 ? 1 : $this->CommentModel->GetOffset($LastCommentID);
                         //                        // Do not load more than a single page of data...
                         //                        $Limit = c('Vanilla.Comments.PerPage', 30);
                         //
                         //                        // Redirect if the new new comment isn't on the same page.
                         //                        $Redirect |= !$DisplayNewCommentOnly && PageNumber($this->Offset, $Limit) != PageNumber($Discussion->CountComments - 1, $Limit);
                         //                     }
                         //                     if ($Redirect) {
                         //                        // The user posted a comment on a page other than the last one, so just redirect to the last page.
                         //                        $this->RedirectUrl = Gdn::request()->Url("discussion/comment/$CommentID/#Comment_$CommentID", true);
                         //                     } else {
                         //                        // Make sure to load all new comments since the page was last loaded by this user
                         //								if ($DisplayNewCommentOnly)
                         $this->Offset = $this->CommentModel->GetOffset($CommentID);
                         $Comments = $this->CommentModel->GetIDData($CommentID, array('Slave' => false));
                         $this->setData('Comments', $Comments);
                         $this->setData('NewComments', true);
                         $this->ClassName = 'DiscussionController';
                         $this->ControllerName = 'discussion';
                         $this->View = 'comments';
                         //                     }
                         // Make sure to set the user's discussion watch records
                         $CountComments = $this->CommentModel->getCount($DiscussionID);
                         $Limit = is_object($this->data('Comments')) ? $this->data('Comments')->numRows() : $Discussion->CountComments;
                         $Offset = $CountComments - $Limit;
                         $this->CommentModel->SetWatch($this->Discussion, $Limit, $Offset, $CountComments);
                     }
                 } else {
                     // If this was a draft save, notify the user about the save
                     $this->informMessage(sprintf(t('Draft saved at %s'), Gdn_Format::date()));
                 }
                 // And update the draft count
                 $UserModel = Gdn::userModel();
                 $CountDrafts = $UserModel->getAttribute($Session->UserID, 'CountDrafts', 0);
                 $this->setJson('MyDrafts', t('My Drafts'));
                 $this->setJson('CountDrafts', $CountDrafts);
             }
         }
     } elseif ($this->Request->isPostBack()) {
         throw new Gdn_UserException(t('Invalid CSRF token.', 'Invalid CSRF token. Please try again.'), 401);
     } else {
         // Load form
         if (isset($this->Comment)) {
             $this->Form->setData((array) $this->Comment);
         }
     }
     // Include data for FireEvent
     if (property_exists($this, 'Discussion')) {
         $this->EventArguments['Discussion'] = $this->Discussion;
     }
     if (property_exists($this, 'Comment')) {
         $this->EventArguments['Comment'] = $this->Comment;
     }
     $this->fireEvent('BeforeCommentRender');
     if ($this->deliveryType() == DELIVERY_TYPE_DATA) {
         if ($this->data('Comments') instanceof Gdn_DataSet) {
             $Comment = $this->data('Comments')->firstRow(DATASET_TYPE_ARRAY);
             if ($Comment) {
                 $Photo = $Comment['InsertPhoto'];
                 if (strpos($Photo, '//') === false) {
                     $Photo = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
                 }
                 $Comment['InsertPhoto'] = $Photo;
             }
             $this->Data = array('Comment' => $Comment);
         }
         $this->RenderData($this->Data);
     } else {
         require_once $this->fetchViewLocation('helper_functions', 'Discussion');
         // Render default view.
         $this->render();
     }
 }
Ejemplo n.º 9
0
">
              <?php 
    echo formatString($menu['title']);
    ?>
            </a>
          </li>
          <?php 
}
?>
          <li>
            <a href="<?php 
echo base_url();
?>
content/body/contact-us">
              <?php 
echo formatString($language->line('header_support'));
?>
            </a>
          </li>
        </ul>
      </div>
  </div>
</footer>
<script src="<?php 
echo base_url();
?>
js/vendor/jquery.min.js"></script>
<script src="<?php 
echo base_url();
?>
js/foundation.min.js"></script>
Ejemplo n.º 10
0
 /**
  * Validate a reCAPTCHA submission.
  *
  * @param string $captchaText
  * @return boolean
  * @throws Exception
  */
 public function validateCaptcha($captchaText)
 {
     $api = new Garden\Http\HttpClient('https://www.google.com/recaptcha/api');
     $data = array('secret' => $this->getPrivateKey(), 'response' => $captchaText);
     $response = $api->get('/siteverify', $data);
     if ($response->isSuccessful()) {
         $result = $response->getBody();
         $errorCodes = val('error_codes', $result);
         if ($result && val('success', $result)) {
             return true;
         } else {
             if (!empty($errorCodes) && $errorCodes != array('invalid-input-response')) {
                 throw new Exception(formatString(t('No response from reCAPTCHA.') . ' {ErrorCodes}', array('ErrorCodes' => join(', ', $errorCodes))));
             }
         }
     } else {
         throw new Exception(t('No response from reCAPTCHA.'));
     }
     return false;
 }
Ejemplo n.º 11
0
 /**
  * Fire before every page render.
  *
  * @param Gdn_Controller $Sender
  */
 public function base_render_before($Sender)
 {
     $Session = Gdn::session();
     if ($Sender->MasterView == 'admin') {
         if (val('Form', $Sender)) {
             $Sender->Form->setStyles('bootstrap');
         }
         $Sender->CssClass = htmlspecialchars($Sender->CssClass);
         $Sections = Gdn_Theme::section(null, 'get');
         if (is_array($Sections)) {
             foreach ($Sections as $Section) {
                 $Sender->CssClass .= ' Section-' . $Section;
             }
         }
         // Get our plugin nav items.
         $navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav());
         $Sender->EventArguments['SideMenu'] = $navAdapter;
         $Sender->fireEvent('GetAppSettingsMenuItems');
         $Sender->removeJsFile('jquery.popup.js');
         $Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard');
         $Sender->addJsFile('dashboard.js', 'dashboard');
         $Sender->addJsFile('jquery.expander.js');
         $Sender->addJsFile('settings.js', 'dashboard');
         $Sender->addJsFile('vendors/tether.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard');
         $Sender->addJsFile('vendors/drop.min.js', 'dashboard');
         $Sender->addJsFile('vendors/moment.min.js', 'dashboard');
         $Sender->addJsFile('vendors/daterangepicker.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard');
         $Sender->addJsFile('vendors/clipboard.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard');
         $Sender->addJsFile('vendors/icheck.min.js', 'dashboard');
         $Sender->addJsFile('jquery.tablejenga.js', 'dashboard');
         $Sender->addJsFile('jquery.fluidfixed.js', 'dashboard');
         $Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ace.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard');
         $Sender->addCssFile('vendors/tomorrow.css', 'dashboard');
     }
     // Check the statistics.
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         Gdn::statistics()->check();
     }
     // Inform user of theme previewing
     if ($Session->isValid()) {
         $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
         $PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', ''));
         $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder));
         $PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder));
         if ($PreviewThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
         if ($PreviewMobileThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->isValid()) {
         $Confirmed = val('Confirmed', Gdn::session()->User, true);
         if (UserModel::requireConfirmEmail() && !$Confirmed) {
             $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->informMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->addModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::factory('Statistics');
         $Gdn_Statistics->check($Sender);
     }
     // Allow forum embedding
     if ($Embed = c('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = c('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->addDefinition('RemoteUrl', $RemoteUrl);
         }
         if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
             $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
         }
         // Force embedding?
         if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
             if (IsMobile()) {
                 $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
             } else {
                 $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
             }
             $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
             $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->addDefinition('Path', Gdn::request()->path());
         $get = Gdn::request()->get();
         unset($get['p']);
         // kludge for old index.php?p=/path
         $Sender->addDefinition('Query', http_build_query($get));
         // $Sender->addDefinition('MasterView', $Sender->MasterView);
         $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->addJsFile('vanilla.embed.local.js');
         } else {
             $Sender->addJsFile('embed_local.js');
         }
     } else {
         $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = val('X-UA-Device-Force', $_COOKIE);
     if ($ForceNoMobile === 'desktop') {
         $Sender->addAsset('Foot', wrap(Anchor(t('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
     // Allow global translation of TagHint
     $Sender->addDefinition("TagHint", t("TagHint", "Start to type..."));
     // Add symbols.
     if ($Sender->deliveryMethod() === DELIVERY_METHOD_XHTML) {
         $Sender->addAsset('Symbols', $Sender->fetchView('symbols', '', 'Dashboard'));
     }
 }
Ejemplo n.º 12
0
 /**
  * Add a method to the ModerationController to handle merging discussions.
  *
  * @param Gdn_Controller $Sender
  */
 public function moderationController_mergeDiscussions_create($Sender)
 {
     $Session = Gdn::session();
     $Sender->Form = new Gdn_Form();
     $Sender->title(t('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::userModel()->getAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->setData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->setData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->whereIn('DiscussionID', $DiscussionIDs)->get('Discussion')->resultArray();
     $Sender->setData('Discussions', $Discussions);
     // Make sure none of the selected discussions are ghost redirects.
     $discussionTypes = array_column($Discussions, 'Type');
     if (in_array('redirect', $discussionTypes)) {
         throw Gdn_UserException('You cannot merge redirects.', 400);
     }
     // Perform the merge
     if ($Sender->Form->authenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = false;
         $MergeDiscussionID = $Sender->Form->getFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         $RedirectLink = $Sender->Form->getFormValue('RedirectLink');
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw permissionException('Vanilla.Discussions.Edit');
             }
             $DiscussionModel->defineSchema();
             $MaxNameLength = val('Length', $DiscussionModel->Schema->getField('Name'));
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->update('Comment')->set('DiscussionID', $MergeDiscussionID)->whereIn('DiscussionID', $DiscussionIDs)->put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = arrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->results(true);
                 $CommentID = $CommentModel->save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(t('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => formatString(t('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->setField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->updateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->removePageCache($Discussion['DiscussionID']);
                     } else {
                         // Delete discussion that was merged.
                         $DiscussionModel->delete($Discussion['DiscussionID']);
                     }
                 } else {
                     $Sender->informMessage($CommentModel->Validation->resultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->updateCommentCount($MergeDiscussionID);
             $CommentModel->removePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::userModel()->saveAttribute($Session->UserID, 'CheckedDiscussions', false);
             ModerationController::informCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->jsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
Ejemplo n.º 13
0
 /**
  *
  *
  * @param $Data
  * @param bool $HomeLink
  * @param array $Options
  * @return string
  */
 public static function breadcrumbs($Data, $HomeLink = true, $Options = array())
 {
     $Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
     $Result = '';
     if (!is_array($Data)) {
         $Data = array();
     }
     if ($HomeLink) {
         $HomeUrl = val('HomeUrl', $Options);
         if (!$HomeUrl) {
             $HomeUrl = Url('/', true);
         }
         $Row = array('Name' => $HomeLink, 'Url' => $HomeUrl, 'CssClass' => 'CrumbLabel HomeCrumb');
         if (!is_string($HomeLink)) {
             $Row['Name'] = T('Home');
         }
         array_unshift($Data, $Row);
     }
     if (val('HideLast', $Options)) {
         // Remove the last item off the list.
         array_pop($Data);
     }
     $DefaultRoute = ltrim(val('Destination', Gdn::router()->getRoute('DefaultController'), ''), '/');
     $Count = 0;
     $DataCount = 0;
     $HomeLinkFound = false;
     foreach ($Data as $Row) {
         $DataCount++;
         if ($HomeLinkFound && Gdn::request()->urlCompare($Row['Url'], $DefaultRoute) === 0) {
             continue;
             // don't show default route twice.
         } else {
             $HomeLinkFound = true;
         }
         // Add the breadcrumb wrapper.
         if ($Count > 0) {
             $Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
         }
         $Row['Url'] = $Row['Url'] ? Url($Row['Url']) : '#';
         $CssClass = 'CrumbLabel ' . val('CssClass', $Row);
         if ($DataCount == count($Data)) {
             $CssClass .= ' Last';
         }
         $Label = '<span class="' . $CssClass . '">' . formatString($Format, $Row) . '</span> ';
         $Result = concatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
         $Count++;
     }
     // Close the stack.
     for ($Count--; $Count > 0; $Count--) {
         $Result .= '</span>';
     }
     $Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
     return $Result;
 }
Ejemplo n.º 14
0
 /**
  * Get a user's permissions.
  *
  * @param int $userID Unique ID of the user.
  * @return Vanilla\Permissions
  */
 public function getPermissions($userID)
 {
     $permissions = new Vanilla\Permissions();
     $permissionsKey = '';
     if (Gdn::cache()->activeEnabled()) {
         $permissionsIncrement = $this->getPermissionsIncrement();
         $permissionsKey = formatString(self::USERPERMISSIONS_KEY, ['UserID' => $userID, 'PermissionsIncrement' => $permissionsIncrement]);
         $cachedPermissions = Gdn::cache()->get($permissionsKey);
         if ($cachedPermissions !== Gdn_Cache::CACHEOP_FAILURE) {
             $permissions->setPermissions($cachedPermissions);
             return $permissions;
         }
     }
     $data = Gdn::permissionModel()->cachePermissions($userID);
     $permissions->compileAndLoad($data);
     $this->EventArguments['UserID'] = $userID;
     $this->EventArguments['Permissions'] = $permissions;
     $this->fireEvent('loadPermissions');
     if (Gdn::cache()->activeEnabled()) {
         Gdn::cache()->store($permissionsKey, $permissions->getPermissions());
     } else {
         // Save the permissions to the user table
         if ($userID > 0) {
             $this->SQL->put('User', ['Permissions' => dbencode($permissions->getPermissions())], ['UserID' => $userID]);
         }
     }
     return $permissions;
 }
Ejemplo n.º 15
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     trace(formatString($message, $context), 'FormattedMessage');
     trace($context, 'context');
 }
Ejemplo n.º 16
0
	<?php 
foreach ($weOfferMenu as $menu) {
    ?>
	<li>
		<a href="<?php 
    echo base_url() . (is_null($menu['url']) ? 'content/body/' . $menu['id'] : $menu['url']);
    ?>
">
			<img src="<?php 
    echo base_url() . $menu['icon'];
    ?>
" alt="<?php 
    echo $menu['title'];
    ?>
" width="20" height="20">&nbsp;<?php 
    echo str_replace('ECommerce', '<small>eCommerce</small>', formatString($menu['title']));
    ?>
</a>
	</li>
	<?php 
}
?>
</ul>
<!-- Newsletter -->
<!-- <hr> -->
<h5 class="color_grey01"><?php 
echo $language->line('sideBar_newsletters');
?>
</h5>
<small><?php 
echo $language->line('newsletters_titleForm');
Ejemplo n.º 17
0
						<?php 
foreach ($services as $array) {
    ?>
						<tr id="tr_<?php 
    echo $array['id'];
    ?>
">
							<td><?php 
    echo $array['name'];
    ?>
</td>
							<td><span class="label radius <?php 
    echo $array['sub_status'] == 'active' ? 'success' : 'alert';
    ?>
"><?php 
    echo formatString($array['sub_status']);
    ?>
</span></td>
							<td>
								<?php 
    $plan = $ci->stripe->getSubscription($array['user_stripe_id'], $array['sub_stripe_id']);
    echo $plan->plan->name;
    ?>
							</td>
							<td><?php 
    echo formatDate($array['sub_created_at']);
    ?>
</td>
							<td><?php 
    echo $array['sub_updated_at'] == '0000-00-00 00:00:00' ? $language->line('services_label_no_updates') : formatDate($array['sub_updated_at']);
    ?>
Ejemplo n.º 18
0
 public function del($id)
 {
     $this->db->del("content", "block_id in (" . formatString($id) . ")");
     $this->db->del("block", "block_id in (" . formatString($id) . ")");
 }
Ejemplo n.º 19
0
 /**
  *
  *
  * @param $Users
  * @param string $UserIDColumn
  * @param string $RolesColumn
  */
 public static function setUserRoles(&$Users, $UserIDColumn = 'UserID', $RolesColumn = 'Roles')
 {
     $UserIDs = array_unique(ConsolidateArrayValuesByKey($Users, $UserIDColumn));
     // Try and get all of the mappings from the cache.
     $Keys = array();
     foreach ($UserIDs as $UserID) {
         $Keys[$UserID] = formatString(UserModel::USERROLES_KEY, array('UserID' => $UserID));
     }
     $UserRoles = Gdn::cache()->get($Keys);
     if (!is_array($UserRoles)) {
         $UserRoles = array();
     }
     // Grab all of the data that doesn't exist from the DB.
     $MissingIDs = array();
     foreach ($Keys as $UserID => $Key) {
         if (!array_key_exists($Key, $UserRoles)) {
             $MissingIDs[$UserID] = $Key;
         }
     }
     if (count($MissingIDs) > 0) {
         $DbUserRoles = Gdn::sql()->select('ur.*')->from('UserRole ur')->whereIn('ur.UserID', array_keys($MissingIDs))->get()->resultArray();
         $DbUserRoles = Gdn_DataSet::Index($DbUserRoles, 'UserID', array('Unique' => false));
         // Store the user role mappings.
         foreach ($DbUserRoles as $UserID => $Rows) {
             $RoleIDs = consolidateArrayValuesByKey($Rows, 'RoleID');
             $Key = $Keys[$UserID];
             Gdn::cache()->store($Key, $RoleIDs);
             $UserRoles[$Key] = $RoleIDs;
         }
     }
     $AllRoles = self::roles();
     // roles indexed by role id.
     // Skip personal info roles
     if (!checkPermission('Garden.PersonalInfo.View')) {
         $AllRoles = array_filter($AllRoles, 'self::FilterPersonalInfo');
     }
     // Join the users.
     foreach ($Users as &$User) {
         $UserID = val($UserIDColumn, $User);
         $Key = $Keys[$UserID];
         $RoleIDs = val($Key, $UserRoles, array());
         $Roles = array();
         foreach ($RoleIDs as $RoleID) {
             if (!array_key_exists($RoleID, $AllRoles)) {
                 continue;
             }
             $Roles[$RoleID] = $AllRoles[$RoleID]['Name'];
         }
         setValue($RolesColumn, $User, $Roles);
     }
 }
 /**
  * Form to ask for the destination of the move, confirmation and permission check.
  */
 public function confirmDiscussionMoves($DiscussionID = null)
 {
     $Session = Gdn::session();
     $this->Form = new Gdn_Form();
     $DiscussionModel = new DiscussionModel();
     $CategoryModel = new CategoryModel();
     $this->title(t('Confirm'));
     if ($DiscussionID) {
         $CheckedDiscussions = (array) $DiscussionID;
         $ClearSelection = false;
     } else {
         $CheckedDiscussions = Gdn::userModel()->getAttribute($Session->User->UserID, 'CheckedDiscussions', array());
         if (!is_array($CheckedDiscussions)) {
             $CheckedDiscussions = array();
         }
         $ClearSelection = true;
     }
     $DiscussionIDs = $CheckedDiscussions;
     $CountCheckedDiscussions = count($DiscussionIDs);
     $this->setData('CountCheckedDiscussions', $CountCheckedDiscussions);
     // Check for edit permissions on each discussion
     $AllowedDiscussions = array();
     $DiscussionData = $DiscussionModel->SQL->select('DiscussionID, Name, DateLastComment, CategoryID, CountComments')->from('Discussion')->whereIn('DiscussionID', $DiscussionIDs)->get();
     $DiscussionData = Gdn_DataSet::Index($DiscussionData->resultArray(), array('DiscussionID'));
     foreach ($DiscussionData as $DiscussionID => $Discussion) {
         $Category = CategoryModel::categories($Discussion['CategoryID']);
         if ($Category && $Category['PermsDiscussionsEdit']) {
             $AllowedDiscussions[] = $DiscussionID;
         }
     }
     $this->setData('CountAllowed', count($AllowedDiscussions));
     $CountNotAllowed = $CountCheckedDiscussions - count($AllowedDiscussions);
     $this->setData('CountNotAllowed', $CountNotAllowed);
     if ($this->Form->authenticatedPostBack()) {
         // Retrieve the category id
         $CategoryID = $this->Form->getFormValue('CategoryID');
         $Category = CategoryModel::categories($CategoryID);
         $RedirectLink = $this->Form->getFormValue('RedirectLink');
         // User must have add permission on the target category
         if (!$Category['PermsDiscussionsAdd']) {
             throw forbiddenException('@' . t('You do not have permission to add discussions to this category.'));
         }
         $AffectedCategories = array();
         // Iterate and move.
         foreach ($AllowedDiscussions as $DiscussionID) {
             $Discussion = val($DiscussionID, $DiscussionData);
             // Create the shadow redirect.
             if ($RedirectLink) {
                 $DiscussionModel->defineSchema();
                 $MaxNameLength = val('Length', $DiscussionModel->Schema->GetField('Name'));
                 $RedirectDiscussion = array('Name' => SliceString(sprintf(t('Moved: %s'), $Discussion['Name']), $MaxNameLength), 'DateInserted' => $Discussion['DateLastComment'], 'Type' => 'redirect', 'CategoryID' => $Discussion['CategoryID'], 'Body' => formatString(t('This discussion has been <a href="{url,html}">moved</a>.'), array('url' => DiscussionUrl($Discussion))), 'Format' => 'Html', 'Closed' => true);
                 // Pass a forced input formatter around this exception.
                 if (c('Garden.ForceInputFormatter')) {
                     $InputFormat = c('Garden.InputFormatter');
                     saveToConfig('Garden.InputFormatter', 'Html', false);
                 }
                 $RedirectID = $DiscussionModel->save($RedirectDiscussion);
                 // Reset the input formatter
                 if (c('Garden.ForceInputFormatter')) {
                     saveToConfig('Garden.InputFormatter', $InputFormat, false);
                 }
                 if (!$RedirectID) {
                     $this->Form->setValidationResults($DiscussionModel->validationResults());
                     break;
                 }
             }
             $DiscussionModel->setField($DiscussionID, 'CategoryID', $CategoryID);
             if (!isset($AffectedCategories[$Discussion['CategoryID']])) {
                 $AffectedCategories[$Discussion['CategoryID']] = array(-1, -$Discussion['CountComments']);
             } else {
                 $AffectedCategories[$Discussion['CategoryID']][0] -= 1;
                 $AffectedCategories[$Discussion['CategoryID']][1] -= $Discussion['CountComments'];
             }
             if (!isset($AffectedCategories[$CategoryID])) {
                 $AffectedCategories[$CategoryID] = array(1, $Discussion['CountComments']);
             } else {
                 $AffectedCategories[$CategoryID][0] += 1;
                 $AffectedCategories[$CategoryID][1] += $Discussion['CountComments'];
             }
         }
         // Update recent posts and counts on all affected categories.
         foreach ($AffectedCategories as $CategoryID => $Counts) {
             $CategoryModel->SetRecentPost($CategoryID);
             $CategoryModel->SQL->update('Category')->set('CountDiscussions', 'CountDiscussions' . ($Counts[0] < 0 ? ' - ' : ' + ') . abs($Counts[0]), false)->set('CountComments', 'CountComments' . ($Counts[1] < 0 ? ' - ' : ' + ') . abs($Counts[1]), false)->where('CategoryID', $CategoryID)->put();
         }
         // Clear selections.
         if ($ClearSelection) {
             Gdn::userModel()->saveAttribute($Session->UserID, 'CheckedDiscussions', false);
             ModerationController::InformCheckedDiscussions($this);
         }
         if ($this->Form->errorCount() == 0) {
             $this->jsonTarget('', '', 'Refresh');
         }
     }
     $this->render();
 }
Ejemplo n.º 21
0
            $classLabel = 'alert';
            break;
        default:
            $classLabel = 'secondary';
            break;
    }
    ?>
							<td><span class='label radius <?php 
    echo $classLabel;
    ?>
'><?php 
    echo str_replace('_', ' ', $array['priority']);
    ?>
</span></td>
							<td><small><?php 
    echo formatString($array['subject']);
    ?>
</small> </td>
							<td><small><?php 
    echo $array['datetime'];
    ?>
</small></td>
						</tr>
						<?php 
}
if (count($tickets) == 0) {
    echo "<tr> <td colspan='6'><h2 >" . $language->line('tickets_no_ticket_to_show') . '</h2></td> </tr>';
}
?>
					</tbody>
				</table>
Ejemplo n.º 22
0
 /**
  * Delete cached data for user
  *
  * @param type $UserID
  * @return type
  */
 public function clearCache($UserID, $CacheTypesToClear = null)
 {
     if (is_null($UserID) || !$UserID) {
         return false;
     }
     if (is_null($CacheTypesToClear)) {
         $CacheTypesToClear = array('user', 'roles', 'permissions');
     }
     if (in_array('user', $CacheTypesToClear)) {
         $UserKey = formatString(self::USERID_KEY, array('UserID' => $UserID));
         Gdn::cache()->remove($UserKey);
     }
     if (in_array('roles', $CacheTypesToClear)) {
         $UserRolesKey = formatString(self::USERROLES_KEY, array('UserID' => $UserID));
         Gdn::cache()->remove($UserRolesKey);
     }
     if (in_array('permissions', $CacheTypesToClear)) {
         Gdn::sql()->put('User', array('Permissions' => ''), array('UserID' => $UserID));
         $PermissionsIncrement = $this->getPermissionsIncrement();
         $UserPermissionsKey = formatString(self::USERPERMISSIONS_KEY, array('UserID' => $UserID, 'PermissionsIncrement' => $PermissionsIncrement));
         Gdn::cache()->remove($UserPermissionsKey);
     }
     return true;
 }
Ejemplo n.º 23
0
 /**
  * Get a record from the database.
  *
  * @param string $recordType The type of record to get. This is usually the un-prefixed table name of the record.
  * @param int $id The ID of the record.
  * @param bool $throw Whether or not to throw an exception if the record isn't found.
  * @return array|false Returns an array representation of the record or false if the record isn't found.
  * @throws Exception Throws an exception with a 404 code if the record isn't found and {@link $throw} is true.
  * @throws Gdn_UserException Throws an exception when {@link $recordType} is unknown.
  */
 function getRecord($recordType, $id, $throw = false)
 {
     $Row = false;
     switch (strtolower($recordType)) {
         case 'discussion':
             $Model = new DiscussionModel();
             $Row = $Model->getID($id);
             $Row->Url = DiscussionUrl($Row);
             $Row->ShareUrl = $Row->Url;
             if ($Row) {
                 return (array) $Row;
             }
             break;
         case 'comment':
             $Model = new CommentModel();
             $Row = $Model->getID($id, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Url'] = Url("/discussion/comment/{$id}#Comment_{$id}", true);
                 $Model = new DiscussionModel();
                 $Discussion = $Model->getID($Row['DiscussionID']);
                 if ($Discussion) {
                     $Discussion->Url = DiscussionUrl($Discussion);
                     $Row['ShareUrl'] = $Discussion->Url;
                     $Row['Name'] = $Discussion->Name;
                     $Row['Discussion'] = (array) $Discussion;
                 }
                 return $Row;
             }
             break;
         case 'activity':
             $Model = new ActivityModel();
             $Row = $Model->getID($id, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Name'] = formatString($Row['HeadlineFormat'], $Row);
                 $Row['Body'] = $Row['Story'];
                 return $Row;
             }
             break;
         default:
             throw new Gdn_UserException('Unknown record type requested.');
     }
     if ($throw) {
         throw NotFoundException();
     } else {
         return false;
     }
 }
Ejemplo n.º 24
0
/**
 * get data from database
 * the true flag parameter in the json_decode function indicates it should return an array
 */
$data = json_decode(self::get_dashboard_widget_option($settings['id'], 'data'), true);
/**
 * Check if there is any data and if so, render the fields
 */
if (isset($data) && sizeof($data) > 0) {
    $length = sizeof($data) / 2;
    echo "<div class=\"quick-info\">";
    echo "<table>";
    for ($i = 1; $i <= $length; $i++) {
        echo "<tr>";
        echo "<td>" . formatString(stripslashes($data['key_' . $i])) . "</td>";
        echo "<td>" . formatString(stripslashes($data['value_' . $i])) . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "</div>";
}
/**
 * Format the data (e.g. render anchor links)
 * @param  String $string the string to format
 * @return String         formatted string
 */
function formatString($string)
{
    if (stripos($string, "href=") > -1 && !stripos($string, "target")) {
        $string = preg_replace('/href="(.+)"/', 'href="$1" target="_blank"', $string);
    } else {
Ejemplo n.º 25
0
 public function fetchPageInfo($Url, $ThrowError = false)
 {
     $PageInfo = FetchPageInfo($Url, 3, $ThrowError);
     $Title = val('Title', $PageInfo, '');
     if ($Title == '') {
         if ($ThrowError) {
             throw new Gdn_UserException(t("The page didn't contain any information."));
         }
         $Title = formatString(t('Undefined discussion subject.'), array('Url' => $Url));
     } else {
         if ($Strip = c('Vanilla.Embed.StripPrefix')) {
             $Title = stringBeginsWith($Title, $Strip, true, true);
         }
         if ($Strip = c('Vanilla.Embed.StripSuffix')) {
             $Title = StringEndsWith($Title, $Strip, true, true);
         }
     }
     $Title = trim($Title);
     $Description = val('Description', $PageInfo, '');
     $Images = val('Images', $PageInfo, array());
     $Body = formatString(t('EmbeddedDiscussionFormat'), array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? img(val(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $Url));
     if ($Body == '') {
         $Body = $Url;
     }
     if ($Body == '') {
         $Body = formatString(t('EmbeddedNoBodyFormat.'), array('Url' => $Url));
     }
     $Result = array('Name' => $Title, 'Body' => $Body, 'Format' => 'Html');
     return $Result;
 }
Ejemplo n.º 26
0
    ?>
img/edit.png" alt="edit" class="cursor_pointer" onclick="redirect('<?php 
    echo base_url();
    ?>
content/manage/<?php 
    echo $array['id'];
    ?>
');">
				<img width="30%" src="<?php 
    echo base_url();
    ?>
img/trash.png" alt="trash" class="cursor_pointer" onclick="deleteRecord(<?php 
    echo $array['id'];
    ?>
,'<?php 
    echo formatString($array['title']);
    ?>
')">
				<img width="30%" src="<?php 
    echo base_url() . 'img/' . ($array['id_status'] == 1 ? 'Checked.png' : 'Unchecked.png');
    ?>
" alt="Status" class="cursor_pointer img_<?php 
    echo $array['id'];
    ?>
" onclick="status_change('<?php 
    echo base_url();
    ?>
content/status/',<?php 
    echo $array['id'];
    ?>
)">
Ejemplo n.º 27
0
 public function forgotPass()
 {
     $this->load->library('email');
     $this->lang->load('emails', $this->session->userdata('ws-language'));
     $user = $this->user->exists($this->input->post('mailForgot'), 'id, name, last_name, email');
     if (!$user) {
         $data = ['out' => 'notOk', 'title' => $this->lang->line('login_forgot_error_title'), 'message' => $this->lang->line('login_forgot_error_message'), 'class' => 'alert', 'title_class' => 'alert-box-title', 'debug' => ''];
     } else {
         $token = md5($user->id . '_' . $user->email . '_' . $user->id);
         $link = base_url() . 'wpanel/resetPass/' . $token;
         $content = '
             <table cellpadding="0" cellspacing="0" border="0" style="width: 100%;  font-size: 14px">
             <tr>
             <td style="padding:10px 0">' . $this->lang->line('email_reset_msg01') . '</td>
             </tr>
             <tr>
             <td style="padding:10px 0">' . $this->lang->line('email_reset_msg02') . '</td>
             </tr>
             <tr>
             <td style="padding:10px 0"><a href="' . $link . '">' . $link . '</a></td>
             </tr>
             </table>
         ';
         $body = $this->load->view('partial/email', ['config' => $this->config->config['head'], 'language' => $this->session->userdata('ws-language'), 'title' => $this->lang->line('login_forgot_title'), 'name' => formatString($user->name . ' ' . $user->last_name), 'content' => $content], true);
         $this->email->initialize(emailSetting());
         $this->email->from($this->config->config['head']['no_reply'][1], $this->config->config['head']['company']);
         $this->email->to($user->email);
         $this->email->subject($this->lang->line('login_forgot_title'));
         $this->email->message($body);
         if (!$this->email->send()) {
             $data = ['out' => 'notOk', 'title' => $this->lang->line('login_forgot_title_error_sending_email'), 'message' => str_replace('[here]', '<a href="' . base_url() . 'content/body/contact-us" style="color:#FFF; text-decoration: underline;">' . $this->lang->line('reset_here_label') . '</a>', $this->lang->line('login_forgot_msg_error_sending_email')), 'class' => 'alert', 'title_class' => 'alert-box-title', 'debugger' => ''];
         } else {
             $data = ['out' => 'ok', 'title' => str_replace('[email]', $user->email, $this->lang->line('login_forgot_ok_title')), 'message' => $this->lang->line('login_forgot_ok_message'), 'class' => 'success', 'title_class' => 'success-box-title'];
         }
     }
     echo json_encode($data);
 }
Ejemplo n.º 28
0
 /**
  * Notifies the current user when one of his questions have been answered.
  *
  * @param NotificationsController $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function notificationsController_beforeInformNotifications_handler($sender, $args)
 {
     $Path = trim($sender->Request->getValue('Path'), '/');
     if (preg_match('`^(vanilla/)?discussion[^s]`i', $Path)) {
         return;
     }
     // Check to see if the user has answered questions.
     $Count = Gdn::SQL()->getCount('Discussion', array('Type' => 'Question', 'InsertUserID' => Gdn::session()->UserID, 'QnA' => 'Answered'));
     if ($Count > 0) {
         $sender->informMessage(formatString(t("You've asked questions that have now been answered", "<a href=\"{/discussions/mine?qna=Answered,url}\">You've asked questions that now have answers</a>. Make sure you accept/reject the answers.")), 'Dismissable');
     }
 }
Ejemplo n.º 29
0
					<img class="content_pic large-6 medium-6 small-12" src="<?php 
echo file_exists($content->image) ? base_url() . $content->image : base_url() . 'img/no-pic.gif';
?>
" alt="<?php 
echo $content->title;
?>
">
					<?php 
echo $content->body;
?>
				</p>
				<div id="servDetail" class="reveal-modal medium" data-reveal>
					<a class="close-reveal-modal">&#215;</a>
					<h5 class="color_green">
						<?php 
echo formatString($service->name);
?>
						<small>
							&nbsp;
							<?php 
echo $content->text_small;
?>
						</small>
					</h5>
					<hr>
					<p>
						<img class="content_pic large-6 medium-6 small-12" src="<?php 
echo file_exists($content->image) ? base_url() . $content->image : base_url() . 'img/no-pic.gif';
?>
" alt="<?php 
echo $content->title;
Ejemplo n.º 30
0
<div class="row panel radius">
	<article>
		<h4 class="color_green"><?php 
echo formatString($content->title . ' ' . $language->line('general_around_the_web'));
?>
		<small>&nbsp;
		<?php 
echo $content->summary;
?>
		</small>
		</h4>
		<?php 
$this->load->view('partial/toolBar.php', ['content' => $content, 'language' => $language, 'socialButtons' => 1]);
?>
		<hr>
		
		<div class="row">
			<div class="large-12 columns">
				<?php 
$this->load->view('partial/blogList.php');
?>
			</div>
		</div>
		<?php 
if ($links) {
    ?>
		<hr>
		<div class="row">
			<div class="large-12 columns">
				<?php 
    echo $links;