Example #1
0
 function map_stageaccess(&$records, &$record)
 {
     if (!isset($this->stages[$record->parent])) {
         return;
     }
     $Access = new MemberAccess();
     $Access->populate($record);
     if (!isset($this->stages[$Access->parent]->rules)) {
         $this->stages[$Access->parent]->rules = array();
     }
     if (!isset($this->stages[$Access->parent]->rules[$Access->name])) {
         $this->stages[$Access->parent]->rules[$Access->name] = array();
     }
     $this->stages[$Access->parent]->rules[$Access->name][] = $Access;
     $records[$record->id] = $Access;
 }
 * Author URI:  http://www.chrisabernethy.com/
 * Text Domain: member_access
 * Domain Path: /wp-content/plugins/member_access/locale
 *
 * Copyright 2008 Chris Abernethy
 *
 * This file is part of Member Access.
 *
 * Member Access is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Member Access is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Member Access.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// Include all class files up-front so that we don't have to worry about the
// include path or any globals containing the plugin base path.
require_once 'lib/MemberAccess/Structure.php';
require_once 'lib/MemberAccess/Structure/Options.php';
require_once 'lib/MemberAccess/Structure/View.php';
require_once 'lib/MemberAccess.php';
// Run the plugin.
MemberAccess::run(__FILE__);
/* EOF */
 /**
  * Determine whether or not the current visibility for the given post is
  * set to 'private'. This method takes into account both the default
  * privacy setting for the type of post given, as well as any override
  * setting on the post itself.
  *
  * If there is not override setting on the given post, and no default has
  * been established for the post type, the post is considered 'public' and
  * false will be returned. This can happen if the post is a type that is not
  * managed by this plugin, either by design or following the introduction of
  * a new post type by WordPress.
  *
  * This method is meant to be called as a static method.
  *
  * @param integer $post_id
  * @return boolean
  */
 function isPrivate($post_id)
 {
     $post = get_post($post_id);
     if (null === $post) {
         return false;
     }
     $plugin = MemberAccess::instance();
     $visibility = $post->{'member_access_visibility'};
     if ('default' === $visibility) {
         if ('post' == $post->post_type && $plugin->getOption('posts_private')) {
             $visibility = 'private';
         }
         if ('page' == $post->post_type && $plugin->getOption('pages_private')) {
             $visibility = 'private';
         }
     }
     return 'private' === $visibility;
 }
Example #4
0
 /**
  * Interface processor for the customer list screen
  *
  * Handles processing customer list actions and displaying the
  * customer list screen
  *
  * @author Jonathan Davis
  * @return void
  **/
 function memeberships()
 {
     $Shopp = Shopp::object();
     $defaults = array('page' => false, 'deleting' => false, 'delete' => false, 'pagenum' => 1, 'per_page' => 20, 's' => '');
     $args = array_merge($defaults, $_GET);
     extract($args, EXTR_SKIP);
     if ($page == $this->Admin->pagename('memberships') && !empty($deleting) && !empty($delete) && is_array($delete)) {
         foreach ($delete as $deletion) {
             $MemberPlan = new MemberPlan($deletion);
             $MemberPlan->delete();
         }
     }
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-save-membership');
         if ($_POST['id'] != "new") {
             $MemberPlan = new MemberPlan($_POST['id']);
         } else {
             $MemberPlan = new MemberPlan();
         }
         $MemberPlan->updates($_POST);
         $MemberPlan->save();
         $MemberPlan->load_stages();
         $stages = array_keys($MemberPlan->stages);
         // Process updates
         foreach ($_POST['stages'] as $i => $stage) {
             if (empty($stage['id'])) {
                 $Stage = new MemberStage($MemberPlan->id);
                 $stage['parent'] = $MemberPlan->id;
             } else {
                 $Stage = new MemberStage($MemberPlan->id, $stage['id']);
             }
             $Stage->updates($stage);
             $Stage->sortorder = $i;
             $Stage->save();
             $Stage->content = array();
             $stage_updates[] = $Stage->id;
             // If the stage data did not save, go to the next stage record
             if (empty($Stage->id)) {
                 continue;
             }
             foreach ($stage['rules'] as $type => $rules) {
                 foreach ($rules as $rule) {
                     $AccessRule = new MemberAccess($Stage->id, $type, $rule['access']);
                     if (empty($AccessRule->id)) {
                         $AccessRule->save();
                     }
                     // If access rule applies to all content, skip content cataloging
                     if (strpos($AccessRule->value, '-all') !== false) {
                         continue;
                     }
                     // Catalog content access rules for this access taxonomy
                     foreach ($rule['content'] as $id => $name) {
                         $CatalogEntry = new MemberContent($id, $AccessRule->id, $Stage->id);
                         if (empty($CatalogEntry->id)) {
                             $CatalogEntry->save();
                         }
                         $Stage->content[$AccessRule->id][$id] = $name;
                     }
                     // endforeach $rule['content']
                 }
                 // endforeach $rules
             }
             // endforeach $stage['rules']
             $Stage->save();
             // Secondary save for specific content rules
         }
         // endforeach $_POST['stages']
     }
     $stageids = array_diff($stages, $stage_updates);
     if (!empty($stageids)) {
         $stagelist = join(',', $stageids);
         // Delete Catalog entries
         $ContentRemoval = new MemberContent();
         sDB::query("DELETE FROM {$ContentRemoval->_table} WHERE 0 < FIND_IN_SET(parent,'{$stagelist}')");
         // Delete Access taxonomies
         $AccessRemoval = new MemberAccess();
         sDB::query("DELETE FROM {$AccessRemoval->_table} WHERE 0 < FIND_IN_SET(parent,'{$stagelist}')");
         // Remove old stages
         $StageRemoval = new MemberStage();
         sDB::query("DELETE FROM {$StageRemoval->_table} WHERE 0 < FIND_IN_SET(id,'{$stagelist}')");
     }
     $pagenum = absint($pagenum);
     if (empty($pagenum)) {
         $pagenum = 1;
     }
     if (!$per_page || $per_page < 0) {
         $per_page = 20;
     }
     $index = $per_page * ($pagenum - 1);
     if (!empty($start)) {
         $startdate = $start;
         list($month, $day, $year) = explode("/", $startdate);
         $starts = mktime(0, 0, 0, $month, $day, $year);
     }
     if (!empty($end)) {
         $enddate = $end;
         list($month, $day, $year) = explode("/", $enddate);
         $ends = mktime(23, 59, 59, $month, $day, $year);
     }
     $membership_table = ShoppDatabaseObject::tablename(MemberPlan::$table);
     $MemberPlan = new MemberPlan();
     $where = '';
     // if (!empty($s)) {
     // 	$s = stripslashes($s);
     // 	if (preg_match_all('/(\w+?)\:(?="(.+?)"|(.+?)\b)/',$s,$props,PREG_SET_ORDER)) {
     // 		foreach ($props as $search) {
     // 			$keyword = !empty($search[2])?$search[2]:$search[3];
     // 			switch(strtolower($search[1])) {
     // 				case "company": $where .= ((empty($where))?"WHERE ":" AND ")."c.company LIKE '%$keyword%'"; break;
     // 				case "login": $where .= ((empty($where))?"WHERE ":" AND ")."u.user_login LIKE '%$keyword%'"; break;
     // 				case "address": $where .= ((empty($where))?"WHERE ":" AND ")."(b.address LIKE '%$keyword%' OR b.xaddress='%$keyword%')"; break;
     // 				case "city": $where .= ((empty($where))?"WHERE ":" AND ")."b.city LIKE '%$keyword%'"; break;
     // 				case "province":
     // 				case "state": $where .= ((empty($where))?"WHERE ":" AND ")."b.state='$keyword'"; break;
     // 				case "zip":
     // 				case "zipcode":
     // 				case "postcode": $where .= ((empty($where))?"WHERE ":" AND ")."b.postcode='$keyword'"; break;
     // 				case "country": $where .= ((empty($where))?"WHERE ":" AND ")."b.country='$keyword'"; break;
     // 			}
     // 		}
     // 	} elseif (strpos($s,'@') !== false) {
     // 		 $where .= ((empty($where))?"WHERE ":" AND ")."c.email='$s'";
     // 	} else $where .= ((empty($where))?"WHERE ":" AND ")." (c.id='$s' OR CONCAT(c.firstname,' ',c.lastname) LIKE '%$s%' OR c.company LIKE '%$s%')";
     //
     // }
     // if (!empty($starts) && !empty($ends)) $where .= ((empty($where))?"WHERE ":" AND ").' (UNIX_TIMESTAMP(c.created) >= '.$starts.' AND UNIX_TIMESTAMP(c.created) <= '.$ends.')';
     $count = sDB::query("SELECT count(*) as total FROM {$MemberPlan->_table} AS c {$where}");
     $query = "SELECT *\n\t\t\t\t\tFROM {$MemberPlan->_table}\n\t\t\t\t\tWHERE parent='{$MemberPlan->parent}'\n\t\t\t\t\t\tAND context='{$MemberPlan->context}'\n\t\t\t\t\t\tAND type='{$MemberPlan->type}'\n\t\t\t\t\tLIMIT {$index},{$per_page}";
     $MemberPlans = sDB::query($query, 'array');
     $num_pages = ceil($count->total / $per_page);
     $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => $num_pages, 'current' => $pagenum));
     $authentication = shopp_setting('account_system');
     include SHOPP_ADMIN_PATH . "/memberships/memberships.php";
 }
 /**
  * This function unhooks the redirections added by MemberAccess.
  *
  * @return void
  *
  * @since PHPDOC
  */
 public static function unhook_redirections()
 {
     /** @noinspection PhpUndefinedClassInspection */
     $aux = MemberAccess::instance();
     remove_filter('the_posts', array(&$aux, 'filterPosts'));
 }