protected function renderContent() { $settings = GxcHelpers::getAvailableSettings(); $type = isset($_GET['type']) ? strtolower(plaintext($_GET['type'])) : 'general'; if (array_key_exists($type, $settings)) { //Import the Setting Class Yii::import('common.settings.' . $type . '.' . $settings[$type]['class']); $model = new $settings[$type]['class'](); foreach ($model->attributes as $attr => $value) { $model->{$attr} = Yii::app()->settings->get($type, $attr); } settings()->deleteCache(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === $type . '-settings-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST[$settings[$type]['class']])) { settings()->deleteCache(); $model->attributes = $_POST[$settings[$type]['class']]; if ($model->validate()) { foreach ($model->attributes as $key => $value) { Yii::app()->settings->set($type, $key, $value); } user()->setFlash('success', t('cms', 'Settings Updated Successfully!')); } } $this->render('common.settings.' . $type . '.' . $settings[$type]['layout'], array('model' => $model)); } else { throw new CHttpException(404, t('cms', 'The requested page does not exist.')); } }
public function actionRender() { $slug = isset($_GET['slug']) ? plaintext($_GET['slug']) : false; if ($slug) { parent::renderPageSlug($slug); } else { throw new CHttpException('404', t('cms', 'Oops! Page not found!')); } }
public function renderPageSlug($slug) { $connection = Yii::app()->db; $command = $connection->createCommand('SELECT * FROM {{page}} WHERE slug=:slug limit 1'); $command->bindValue(':slug', $slug, PDO::PARAM_STR); $page = $command->queryRow(); if ($page) { //We first need to check if having Ajax Request if (isset($_REQUEST['ajax']) && strpos($_REQUEST['ajax'], ConstantDefine::AJAX_BLOCK_SEPERATOR) !== false) { $ajax = explode(ConstantDefine::AJAX_BLOCK_SEPERATOR, plaintext($_REQUEST['ajax'])); $block_id = $ajax[1]; $id = $ajax[0]; $block_ini = parse_ini_file(Yii::getPathOfAlias('common.blocks.' . $id) . DIRECTORY_SEPARATOR . 'info.ini'); //Include the class Yii::import('common.blocks.' . $id . '.' . $block_ini['class']); $layout_asset = GxcHelpers::publishAsset(Yii::getPathOfAlias('common.layouts.' . $page['layout'] . '.assets')); //Get the Block $command = $connection->createCommand('SELECT b.block_id,b.name,b.type,b.params FROM {{block}} b WHERE b.block_id=:bid Limit 1'); $command->bindValue(':bid', $block_id, PDO::PARAM_INT); $block = $command->queryRow(); if ($block !== false) { $this->widget('common.blocks.' . $id . '.' . $block_ini['class'], array('block' => $block, 'page' => $page, 'layout_asset' => $layout_asset)); } else { echo ''; } Yii::app()->end(); } else { $this->layout = 'main'; $this->pageTitle = $page['title']; $this->description = $page['description']; $this->keywords = $page['keywords']; //depend on the layout of the page, use the corresponding file to render $this->renderPage('common.layouts.' . $page['layout'] . '.' . $page['display_type'], array('page' => $page)); } } else { throw new CHttpException('404', t('cms', 'Oops! Page not found!')); } }
function gpluspost_send(&$a, &$b) { logger('gpluspost_send: invoked for post ' . $b['id'] . " " . $b['app']); if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'gplus')) { return; } if ($b['parent'] != $b['id']) { return; } // if post comes from Google+ don't send it back if (!get_pconfig($b["uid"], 'gpluspost', 'no_loop_prevention') and ($b['app'] == "Google+" or $b["extid"] == NETWORK_GPLUS)) { return; } if (!gpluspost_nextscripts()) { // Posting via RSS-Feed and Hootsuite $itemlist = get_pconfig($b["uid"], 'gpluspost', 'itemlist'); $items = explode(",", $itemlist); $i = 0; $newitems = array($b['id']); foreach ($items as $item) { if ($i++ < 9) { $newitems[] = $item; } } $itemlist = implode(",", $newitems); logger('gpluspost_send: new itemlist: ' . $itemlist . " for uid " . $b["uid"]); set_pconfig($b["uid"], 'gpluspost', 'itemlist', $itemlist); } else { // Posting via NextScripts $username = get_pconfig($b['uid'], 'gpluspost', 'username'); $password = get_pconfig($b['uid'], 'gpluspost', 'password'); $page = get_pconfig($b['uid'], 'gpluspost', 'page'); $success = false; if ($username && $password) { require_once "addon/gpluspost/postToGooglePlus.php"; require_once "include/plaintext.php"; $item = $b; // Markup for Google+ if ($item["title"] != "") { $item["title"] = "*" . $item["title"] . "*"; } $item["body"] = preg_replace("(\\[b\\](.*?)\\[\\/b\\])ism", '*$1*', $item["body"]); $item["body"] = preg_replace("(\\[i\\](.*?)\\[\\/i\\])ism", '_$1_', $item["body"]); $item["body"] = preg_replace("(\\[s\\](.*?)\\[\\/s\\])ism", '-$1-', $item["body"]); $data = plaintext($a, $item, 0, false, 9); logger('gpluspost_send: data: ' . print_r($data, true), LOGGER_DEBUG); $loginError = doConnectToGooglePlus2($username, $password); if (!$loginError) { if ($data["url"] != "") { $lnk = doGetGoogleUrlInfo2($data["url"]); } elseif ($data["image"] != "") { $lnk = array('img' => $data["image"]); } else { $lnk = ""; } // Send a special blank to identify the post through the "fromgplus" addon $blank = html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); doPostToGooglePlus2($data["text"] . $blank, $lnk, $page); $success = true; logger('gpluspost_send: ' . $b['uid'] . ' success', LOGGER_DEBUG); } else { logger('gpluspost_send: ' . $b['uid'] . ' failed ' . $loginError, LOGGER_DEBUG); } if (!$success) { logger('gpluspost_send: requeueing ' . $b['uid'], LOGGER_DEBUG); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", $b['uid']); if (count($r)) { $a->contact = $r[0]["id"]; } $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $data)); require_once 'include/queue_fn.php'; add_to_queue($a->contact, NETWORK_GPLUS, $s); notice(t('Google+ post failed. Queued for retry.') . EOL); } } else { logger('gpluspost_send: ' . $b['uid'] . ' missing username or password', LOGGER_DEBUG); } } }
<?php $this->breadcrumbs = array('Rights' => Rights::getBaseUrl(), Rights::t('core', 'Permissions')); ?> <div id="permissions"> <?php $app = isset($_GET['app']) ? strtolower(plaintext($_GET['app'])) : strtolower(app()->id); Yii::app()->controller->pageTitle = Rights::t('core', 'Permissions') . ' - ' . ucfirst($app) . ' Application'; ?> <?php $apps = GxcHelpers::getAllApps(); ?> <p> <?php foreach ($apps as $app) { ?> <?php echo CHtml::link(Rights::t('core', 'Set permissions for') . ' ' . ucfirst($app), array('authItem/permissions', 'app' => $app), array('class' => 'generator-link')); ?> | <?php } ?> </p> <p> <?php
function appnet_prepare_body(&$a, &$b) { if ($b["item"]["network"] != NETWORK_APPNET) { return; } if ($b["preview"]) { $max_char = 256; require_once "include/plaintext.php"; $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", dbesc($item["thr-parent"]), intval(local_user())); if (count($r)) { $orig_post = $r[0]; $nicknameplain = preg_replace("=https?://alpha.app.net/(.*)=ism", "\$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; if (strpos($item["body"], $nickname) === false and strpos($item["body"], $nicknameplain) === false) { $item["body"] = $nickname . " " . $item["body"]; } } $msgarr = plaintext($a, $item, $max_char, true); $msg = appnet_create_entities($a, $item, $msgarr); require_once "library/markdown.php"; $msg = Markdown($msg); $b['html'] = $msg; } }
function twitter_prepare_body(&$a, &$b) { if ($b["item"]["network"] != NETWORK_TWITTER) { return; } if ($b["preview"]) { $max_char = 140; require_once "include/plaintext.php"; $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", dbesc($item["thr-parent"]), intval(local_user())); if (count($r)) { $orig_post = $r[0]; $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "\$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; if (strpos($item["body"], $nickname) === false and strpos($item["body"], $nicknameplain) === false) { $item["body"] = $nickname . " " . $item["body"]; } } $msgarr = plaintext($a, $item, $max_char, true, 8); $msg = $msgarr["text"]; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { $msg .= " " . $msgarr["url"]; } if (isset($msgarr["image"])) { $msg .= " " . $msgarr["image"]; } $b['html'] = nl2br(htmlspecialchars($msg)); } }
function statusnet_prepare_body(&$a, &$b) { if ($b["item"]["network"] != NETWORK_STATUSNET) { return; } if ($b["preview"]) { $max_char = get_pconfig(local_user(), 'statusnet', 'max_char'); if (intval($max_char) == 0) { $max_char = 140; } require_once "include/plaintext.php"; $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick\n FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($item["thr-parent"]), intval(local_user())); if (count($r)) { $orig_post = $r[0]; //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; //$nicknameplain = "@".$orig_post["contact_nick"]; $nick = preg_replace("=https?://(.*)/(.*)=ism", "\$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nicknameplain = "@" . $nick; if (strpos($item["body"], $nickname) === false and strpos($item["body"], $nicknameplain) === false) { $item["body"] = $nickname . " " . $item["body"]; } } $msgarr = plaintext($a, $item, $max_char, true, 7); $msg = $msgarr["text"]; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { $msg .= " " . $msgarr["url"]; } if (isset($msgarr["image"])) { $msg .= " " . $msgarr["image"]; } $b['html'] = nl2br(htmlspecialchars($msg)); } }
/** * @param App $a * @param object $b * @return mixed */ function fbpost_post_hook(&$a, &$b) { logger('fbpost_post_hook: Facebook post invoked', LOGGER_DEBUG); if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } logger('fbpost_post_hook: Facebook post first check successful', LOGGER_DEBUG); // if post comes from facebook don't send it back if ($b['extid'] == NETWORK_FACEBOOK) { return; } if ($b['app'] == "Facebook" and $b['verb'] != ACTIVITY_LIKE) { return; } logger('fbpost_post_hook: Facebook post accepted', LOGGER_DEBUG); /** * Post to Facebook stream */ require_once 'include/group.php'; require_once 'include/html2plain.php'; $reply = false; $likes = false; $deny_arr = array(); $allow_arr = array(); $toplevel = $b['id'] == $b['parent'] ? true : false; $linking = get_pconfig($b['uid'], 'facebook', 'no_linking') ? 0 : 1; if (!$toplevel && $linking) { $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), intval($b['uid'])); //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", // dbesc($b['parent-uri']), // intval($b['uid']) //); // is it a reply to a facebook post? // A reply to a toplevel post is only allowed for "real" facebook posts if (count($r) && substr($r[0]['uri'], 0, 4) === 'fb::') { $reply = substr($r[0]['uri'], 4); } elseif (count($r) && substr($r[0]['extid'], 0, 4) === 'fb::' and $r[0]['id'] != $r[0]['parent']) { $reply = substr($r[0]['extid'], 4); } else { return; } $u = q("SELECT * FROM user where uid = %d limit 1", intval($b['uid'])); if (!count($u)) { return; } // only accept comments from the item owner. Other contacts are unknown to FB. if (!link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname'])) { return; } logger('fbpost_post_hook: facebook reply id=' . $reply); } if (strstr($b['postopts'], 'facebook') || $b['private'] || $reply) { if ($b['private'] && $reply === false) { $allow_people = expand_acl($b['allow_cid']); $allow_groups = expand_groups(expand_acl($b['allow_gid'])); $deny_people = expand_acl($b['deny_cid']); $deny_groups = expand_groups(expand_acl($b['deny_gid'])); $recipients = array_unique(array_merge($allow_people, $allow_groups)); $deny = array_unique(array_merge($deny_people, $deny_groups)); $allow_str = dbesc(implode(', ', $recipients)); if ($allow_str) { logger("fbpost_post_hook: private post to: " . $allow_str, LOGGER_DEBUG); $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$allow_str} ) AND `network` = 'face'"); if (count($r)) { foreach ($r as $rr) { $allow_arr[] = $rr['notify']; } } } $deny_str = dbesc(implode(', ', $deny)); if ($deny_str) { $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$deny_str} ) AND `network` = 'face'"); if (count($r)) { foreach ($r as $rr) { $deny_arr[] = $rr['notify']; } } } if (count($deny_arr) && !count($allow_arr)) { // One or more FB folks were denied access but nobody on FB was specifically allowed access. // This might cause the post to be open to public on Facebook, but only to selected members // on another network. Since this could potentially leak a post to somebody who was denied, // we will skip posting it to Facebook with a slightly vague but relevant message that will // hopefully lead somebody to this code comment for a better explanation of what went wrong. notice(t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL); return; } // if it's a private message but no Facebook members are allowed or denied, skip Facebook post if (!count($allow_arr) && !count($deny_arr)) { return; } } if ($b['verb'] == ACTIVITY_LIKE) { $likes = true; logger('fbpost_post_hook: liking ' . print_r($b, true), LOGGER_DEBUG); } $appid = get_config('facebook', 'appid'); $secret = get_config('facebook', 'appsecret'); if ($appid && $secret) { logger('fbpost_post_hook: have appid+secret'); $fb_token = get_pconfig($b['uid'], 'facebook', 'access_token'); // post to facebook if it's a public post and we've ticked the 'post to Facebook' box, // or it's a private message with facebook participants // or it's a reply or likes action to an existing facebook post if ($fb_token && ($toplevel || $b['private'] || $reply)) { logger('fbpost_post_hook: able to post'); require_once 'library/facebook.php'; require_once 'include/bbcode.php'; $msg = $b['body']; logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA); if ($toplevel) { require_once "include/plaintext.php"; $msgarr = plaintext($a, $b, 0, false, 9); $msg = $msgarr["text"]; $link = $msgarr["url"]; $linkname = $msgarr["title"]; if ($msgarr["type"] != "video") { $image = $msgarr["image"]; } // Fallback - if message is empty if (!strlen($msg)) { $msg = $linkname; } if (!strlen($msg)) { $msg = $link; } if (!strlen($msg)) { $msg = $image; } } else { require_once "include/bbcode.php"; require_once "include/html2plain.php"; $msg = bb_CleanPictureLinks($msg); $msg = bbcode($msg, false, false, 2, true); $msg = trim(html2plain($msg, 0)); $link = ""; $image = ""; $linkname = ""; } // If there is nothing to post then exit if (!strlen($msg)) { return; } logger('fbpost_post_hook: msg=' . $msg, LOGGER_DATA); $video = ""; if ($likes) { $postvars = array('access_token' => $fb_token); } else { // message, picture, link, name, caption, description, source, place, tags //if(trim($link) != "") // if (@exif_imagetype($link) != 0) { // $image = $link; // $link = ""; // } $postvars = array('access_token' => $fb_token, 'message' => $msg); if (trim($image) != "") { $postvars['picture'] = $image; } if (trim($link) != "") { $postvars['link'] = $link; if (stristr($link, 'youtube') || stristr($link, 'youtu.be') || stristr($link, 'vimeo')) { $video = $link; } } if (trim($linkname) != "") { $postvars['name'] = $linkname; } } if ($b['private'] && $toplevel) { $postvars['privacy'] = '{"value": "CUSTOM", "friends": "SOME_FRIENDS"'; if (count($allow_arr)) { $postvars['privacy'] .= ',"allow": "' . implode(',', $allow_arr) . '"'; } if (count($deny_arr)) { $postvars['privacy'] .= ',"deny": "' . implode(',', $deny_arr) . '"'; } $postvars['privacy'] .= '}'; } $post_to_page = get_pconfig($b['uid'], 'facebook', 'post_to_page'); $page_access_token = get_pconfig($b['uid'], 'facebook', 'page_access_token'); if (intval($post_to_page) != 0 and $page_access_token != "") { $target = $post_to_page; } else { $target = "me"; } if ($reply) { $url = 'https://graph.facebook.com/' . $reply . '/' . ($likes ? 'likes' : 'comments'); } else { if ($video != "" or $image == "" and $link != "") { // If it is a link to a video or a link without a preview picture then post it as a link if ($video != "") { $link = $video; } $postvars = array('access_token' => $fb_token, 'link' => $link); if ($msg != $video) { $postvars['message'] = $msg; } $url = 'https://graph.facebook.com/' . $target . '/links'; } else { if ($link == "" and $image != "") { // If it is only an image without a page link then post this image as a photo $postvars = array('access_token' => $fb_token, 'url' => $image); if ($msg != $image) { $postvars['message'] = $msg; } $url = 'https://graph.facebook.com/' . $target . '/photos'; //} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) { } else { $url = 'https://graph.facebook.com/' . $target . '/feed'; if (!get_pconfig($b['uid'], 'facebook', 'suppress_view_on_friendica') and $b['plink']) { $postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}'; } } } } /* } else { // if its only a message and a subject and the message is larger than 500 characters then post it as note $postvars = array( 'access_token' => $fb_token, 'message' => bbcode($b['body'], false, false), 'subject' => $b['title'], ); $url = 'https://graph.facebook.com/'.$target.'/notes'; } */ // Post to page? if (!$reply and $target != "me" and $page_access_token) { $postvars['access_token'] = $page_access_token; } logger('fbpost_post_hook: post to ' . $url); logger('fbpost_post_hook: postvars: ' . print_r($postvars, true)); // "test_mode" prevents anything from actually being posted. // Otherwise, let's do it. if (!get_config('facebook', 'test_mode')) { $x = post_url($url, $postvars); logger('fbpost_post_hook: post returns: ' . $x, LOGGER_DEBUG); $retj = json_decode($x); if ($retj->id) { // Only set the extid when it isn't the toplevel post q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d AND `parent` != %d", dbesc('fb::' . $retj->id), intval($b['id']), intval($b['id'])); } else { // Sometimes posts are accepted from facebook although it telling an error // This leads to endless comment flooding. // If it is a special kind of failure the post was receiced // Although facebook said it wasn't received ... if (!$likes and ($retj->error->type != "OAuthException" or $retj->error->code != 2) and $x != "") { $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid'])); if (count($r)) { $a->contact = $r[0]["id"]; } $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $postvars)); require_once 'include/queue_fn.php'; add_to_queue($a->contact, NETWORK_FACEBOOK, $s); logger('fbpost_post_hook: Post failed, requeued.', LOGGER_DEBUG); notice(t('Facebook post failed. Queued for retry.') . EOL); } if (isset($retj->error) && $retj->error->type == "OAuthException" && $retj->error->code == 190) { logger('fbpost_post_hook: Facebook session has expired due to changed password.', LOGGER_DEBUG); $last_notification = get_pconfig($b['uid'], 'facebook', 'session_expired_mailsent'); if (!$last_notification || $last_notification < time() - FACEBOOK_SESSION_ERR_NOTIFICATION_INTERVAL) { require_once 'include/enotify.php'; $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($b['uid'])); notification(array('uid' => $b['uid'], 'type' => NOTIFY_SYSTEM, 'system_type' => 'facebook_connection_invalid', 'language' => $r[0]['language'], 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'source_name' => t('Administrator'), 'source_link' => $a->config["system"]["url"], 'source_photo' => $a->config["system"]["url"] . '/images/person-80.jpg')); set_pconfig($b['uid'], 'facebook', 'session_expired_mailsent', time()); } else { logger('fbpost_post_hook: No notification, as the last one was sent on ' . $last_notification, LOGGER_DEBUG); } } } } } } } }
function buffer_send(&$a, &$b) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'buffer')) { return; } if ($b['parent'] != $b['id']) { return; } // if post comes from buffer don't send it back //if($b['app'] == "Buffer") // return; $client_id = get_config("buffer", "client_id"); $client_secret = get_config("buffer", "client_secret"); $access_token = get_pconfig($b['uid'], "buffer", "access_token"); if ($access_token) { $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token); require_once "include/plaintext.php"; require_once "include/network.php"; $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { logger("Will send these parameter " . print_r($b, true), LOGGER_DEBUG); foreach ($profiles as $profile) { if (!$profile->default) { continue; } $send = false; switch ($profile->service) { case 'appdotnet': $send = $b["extid"] != NETWORK_APPNET; $limit = 256; $markup = false; $includedlinks = true; $htmlmode = 6; break; case 'facebook': $send = $b["extid"] != NETWORK_FACEBOOK; $limit = 0; $markup = false; $includedlinks = false; $htmlmode = 9; break; case 'google': $send = $b["extid"] != NETWORK_GPLUS; $limit = 0; $markup = true; $includedlinks = false; $htmlmode = 9; break; case 'twitter': $send = $b["extid"] != NETWORK_TWITTER; $limit = 140; $markup = false; $includedlinks = true; $htmlmode = 8; break; case 'linkedin': $send = $b["extid"] != NETWORK_LINKEDIN; $limit = 700; $markup = false; $includedlinks = true; $htmlmode = 2; break; } if (!$send) { continue; } $item = $b; // Markup for Google+ if ($markup) { if ($item["title"] != "") { $item["title"] = "*" . $item["title"] . "*"; } $item["body"] = preg_replace("(\\[b\\](.*?)\\[\\/b\\])ism", '*$1*', $item["body"]); $item["body"] = preg_replace("(\\[i\\](.*?)\\[\\/i\\])ism", '_$1_', $item["body"]); $item["body"] = preg_replace("(\\[s\\](.*?)\\[\\/s\\])ism", '-$1-', $item["body"]); } $post = plaintext($a, $item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message " . $b["id"] . " result: " . print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures require_once "mod/proxy.php"; if (isset($post["image"])) { $post["image"] = proxy_url($post["image"]); } if (isset($post["preview"])) { $post["preview"] = proxy_url($post["preview"]); } //if ($profile->service == "twitter") { if ($includedlinks) { if (isset($post["url"])) { $post["url"] = short_link($post["url"]); } if (isset($post["image"])) { $post["image"] = short_link($post["image"]); } if (isset($post["preview"])) { $post["preview"] = short_link($post["preview"]); } } // Seems like a bug to me // Buffer doesn't add links to Twitter and App.net (but pictures) //if ($includedlinks AND isset($post["url"])) if ($profile->service == "twitter" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and isset($post["title"]) and $post["type"] != "photo") { $post["title"] = shortenmsg($post["title"], 90); $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[" . $post["title"] . "](" . $post["url"] . ")"; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "google") { $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); } // Send a special blank to identify the post through the "fromgplus" addon $message = array(); $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false; $message["now"] = true; if (isset($post["title"])) { $message["media[title]"] = $post["title"]; } if (isset($post["description"])) { $message["media[description]"] = $post["description"]; } if (isset($post["url"]) and $post["type"] != "photo") { $message["media[link]"] = $post["url"]; } if (isset($post["image"])) { $message["media[picture]"] = $post["image"]; if ($post["type"] == "photo") { $message["media[thumbnail]"] = $post["image"]; } } if (isset($post["preview"])) { $message["media[thumbnail]"] = $post["preview"]; } //print_r($message); logger("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); $ret = $buffer->go('/updates/create', $message); logger("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); } } } }
/** * Displays the generator page. */ public function actionGenerate() { // Get the generator and authorizer $generator = $this->module->getGenerator(); // Createh the form model $model = new GenerateForm(); // Form has been submitted if (isset($_POST['GenerateForm']) === true) { // Form is valid $model->attributes = $_POST['GenerateForm']; if ($model->validate() === true) { $items = array('tasks' => array(), 'operations' => array()); // Get the chosen items foreach ($model->items as $itemname => $value) { if ((bool) $value === true) { //Tuan Implement to add App ID here //Get App ID $app = isset($_GET['app']) ? strtolower(plaintext($_GET['app'])) : strtolower(Yii::app()->id); if (strpos($itemname, '*') !== false) { $items['tasks'][] = $itemname; } else { $items['operations'][] = $itemname; } } } // Add the items to the generator as tasks and operations and run the generator. $generator->addItems($items['tasks'], CAuthItem::TYPE_TASK); $generator->addItems($items['operations'], CAuthItem::TYPE_OPERATION); if (($generatedItems = $generator->run()) !== false && $generatedItems !== array()) { Yii::app()->getUser()->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Authorization items created.')); $this->redirect(array('authItem/permissions')); } } } // Get all items that are available to be generated $items = $generator->getControllerActions(); // We need the existing operations for comparason $authItems = $this->_authorizer->getAuthItems(array(CAuthItem::TYPE_TASK, CAuthItem::TYPE_OPERATION)); $existingItems = array(); foreach ($authItems as $itemName => $item) { $existingItems[$itemName] = $itemName; } Yii::app()->clientScript->registerScript('rightsGenerateItemTableSelectRows', "jQuery('.generate-item-table').rightsSelectRows();"); // Render the view $this->render('generate', array('model' => $model, 'items' => $items, 'existingItems' => $existingItems)); }
/** * Returns a list of all application controllers. * @return array the controllers. */ protected function getAllControllers() { $items['controllers'] = array(); $items['modules'] = array(); //Get App Path $app = isset($_GET['app']) ? strtolower(plaintext($_GET['app'])) : false; // Tuan Implement to look for module controllers in common and cms folder also //If there is no $_GET['app'], we will use the current app if (!$app) { $basePath = Yii::app()->basePath; } else { $basePath = Yii::app()->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'protected'; } if (is_dir($basePath)) { //Look for controller in current app $items['controllers'] = $this->getControllersInPath($basePath . DIRECTORY_SEPARATOR . 'controllers'); //Look for module controller in current app $items['modules'] = $this->getControllersInModules($basePath); //Look for module controller in common folder $items['modules'] = array_merge($items['modules'], $this->getControllersInModules(Yii::getPathOfAlias('common'))); //Look for module controller in cms folder $items['modules'] = array_merge($items['modules'], $this->getControllersInModules(Yii::getPathOfAlias('cms'))); } return $items; }
/** * Generates the data for the data provider. */ protected function generateData() { $data = array(); $permissions = $this->_permissions; $parents = $this->_parents; foreach ($this->_items as $itemName => $item) { $row = array(); $row['description'] = $item->getNameLink(); $row['name'] = $item->name; foreach ($this->_roles as $roleName => $role) { // Item is directly assigned to the role if ($permissions[$roleName][$itemName] === Rights::PERM_DIRECT) { $permissionColumn = $item->getRevokePermissionLink($role); } else { if ($permissions[$roleName][$itemName] === Rights::PERM_INHERITED && isset($parents[$roleName][$itemName]) === true) { $permissionColumn = $item->getInheritedPermissionText($parents[$roleName][$itemName], $this->displayParentType); } else { $permissionColumn = $item->getAssignPermissionLink($role); } } // Populate role column $row[strtolower($roleName)] = isset($permissionColumn) === true ? $permissionColumn : ''; } // Append the row to data $data[] = $row; } //Tuan implement to show Item based on App only //Get App Path $app = isset($_GET['app']) ? strtolower(plaintext($_GET['app'])) : strtolower(app()->id); $data_filter = array(); foreach ($data as $key => $item) { if (strpos($item['name'], $app) !== false) { //Strip Item that is not based on current app $data_filter[] = $data[$key]; } } $this->setData($data_filter); }