/**
  * displays the form
  * @return none
  */
 function addRole()
 {
     $table =& bTable::getInstance($this->table, 'Table');
     $properties = $table->getProperties();
     echo '<form action="#" method="get" name="formadd" id="formadd">';
     //create the form
     foreach ($properties as $property => $value) {
         if ($table->getKeyName() == $property) {
             continue;
         }
         if ('capabilities' == $property) {
             continue;
         }
         $label = ucwords(strtolower(str_replace('_', ' ', $property)));
         echo '<label>' . $label . '<br>';
         echo '<input type="text" name="' . $property . '" id="' . $property . '"></label><br>';
     }
     echo '</form>';
 }
 function byrd_create_user($username, $email, $password = false)
 {
     $_tbl =& bTable::getInstance('users', 'Table');
     if (!$password) {
         $password = byrd_generate_password(12, false);
     }
     //save this to the database
     $_tbl->bind(array('user_login' => $username, 'user_pass' => byrd_hash_password($password), 'user_nicename' => $username, 'user_email' => $email, 'user_registered' => date('Y-m-d H:i:s'), 'user_status' => 0, 'display_name' => $username));
     $_tbl->store();
     return $_tbl->ID;
 }
Exemple #3
0
 /**
  * Check if an item is checked out
  *
  * This function can be used as a static function too, when you do so you need to also provide the
  * a value for the $against parameter.
  *
  * @static
  * @access public
  * @param integer  $with  	The userid to preform the match with, if an item is checked out
  * 				  			by this user the function will return false
  * @param integer  $against 	The userid to perform the match against when the function is used as
  * 							a static function.
  * @return boolean
  */
 function isCheckedOut($with = 0, $against = null)
 {
     if (isset($this) && is_a($this, 'bTable') && is_null($against)) {
         $against = $this->get('checked_out');
     }
     //item is not checked out, or being checked out by the same user
     if (!$against || $against == $with) {
         return false;
     }
     $session =& bTable::getInstance('session');
     return $session->exists($against);
 }
 /**
  * gets the list of data
  * @return none
  */
 function viewform()
 {
     // getting the table reference
     $table =& bTable::getInstance($this->table, 'Table');
     //get the table
     $table->load($this->ID);
     echo $table->html;
 }
 /**
  * loads all user data from the cookie
  * 
  * @return bool
  */
 function loadUser()
 {
     //getting the users name
     if (!($this->username = byrd_getusername())) {
         return false;
     }
     //getting the user data
     $user =& bTable::getInstance('users', 'Table');
     $userdata = $user->username_exists($this->username);
     $this->user_id = $userdata['ID'];
     $user->load($this->user_id);
     //getting the users meta data
     $usermeta =& bTable::getInstance('usermeta', 'Table');
     $usermeta->user_id = $this->user_id;
     $usermetadata = $usermeta->getMeta();
     $userdata['meta'] = $usermetadata;
     //binding
     $this->loadMeta($usermetadata, 'word_user_level');
     $this->loadMeta($usermetadata, 'word_capabilities');
     //special binds
     $this->user_role = ucwords(key(unserialize($this->word_capabilities)));
     return $userdata;
 }
    /**
     * returns the complete formatted subscriptions
     * <!-- getSubscription() -->
     * 
     * @param $content
     * @return unknown_type
     */
    function getSubscriptions()
    {
        $return = '';
        $sub =& bTable::getInstance('subscriptions', 'Table');
        if ($this->pp_sandbox) {
            $action = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
        } else {
            $action = 'https://www.paypal.com/cgi-bin/webscr';
        }
        if (!is_array($subscriptions = $sub->getList())) {
            return '<!-- No Subscriptions exist. -->';
        }
        foreach ($subscriptions as $sub) {
            $return .= '<h3>' . $sub['item_name'] . '</h3>
			<div class="left width75">' . $sub['item_description'] . '</div>
			<div class="left width25">$' . $sub['a3'] . '</div>
			<div class="clear"></div>
			
<div style="position:relative;float:right;"> 
 <form action="' . $action . '" method="post">
  <input type="hidden" name="cmd" value="_xclick-subscriptions">
  <input type="hidden" name="item_number" value="' . $sub['itemid'] . '">
    ';
            foreach ($this->getProperties() as $property => $value) {
                if (is_null($this->{$property}) || !$this->{$property}) {
                    continue;
                }
                if (in_array($property, array('role', 'item_number', 'status', 'downgradeuser', 'custom', 'displayexpirationdata', 'old_roles', 'wp_filter_id'))) {
                    continue;
                }
                $return .= '<input type="hidden" name="' . $property . '" value="' . $value . '"> ';
            }
            foreach ($sub as $property => $value) {
                if (is_null($sub[$property]) || !$sub[$property]) {
                    continue;
                }
                if (in_array($property, array('role', 'item_number', 'status', 'downgradeuser', 'custom', 'displayexpirationdata', 'old_roles', 'wp_filter_id'))) {
                    continue;
                }
                $return .= '<input type="hidden" name="' . $property . '" value="' . $value . '">';
            }
            $return .= ' 
    <input type="hidden" name="custom" value="' . $this->calc_expiration($sub['p3'], $sub['t3'], $sub['srt']) . '">
  <input type="submit" name="submit" value="' . $sub['buy_button'] . '" border="0" alt="PayPal - The safer, easier way to pay online">
  
 </form>
</div>
			<div style="display:block;width:100%;clear:both;height:1px;line-height:1px;"></div>';
        }
        return $return;
    }
Exemple #7
0
 /**
  * stores the submission to the database regardless
  * @return 
  */
 function storeUserData()
 {
     if (!isset($this->userid)) {
         return false;
     }
     update_usermeta($this->userid, 'subscription_expiration', $this->custom);
     update_usermeta($this->userid, 'subscription_startdate', $this->payment_date);
     update_usermeta($this->userid, 'subscription_name', $this->item_name);
     update_usermeta($this->userid, 'subscription_streetaddress', $this->address_street);
     update_usermeta($this->userid, 'subscription_city', $this->address_city);
     update_usermeta($this->userid, 'subscription_state', $this->address_state);
     update_usermeta($this->userid, 'subscription_zip', $this->address_zip);
     update_usermeta($this->userid, 'subscription_country', $this->address_country);
     update_usermeta($this->userid, 'first_name', $this->first_name);
     update_usermeta($this->userid, 'last_name', $this->last_name);
     $data['display_name'] = $this->first_name . ' ' . $this->last_name;
     $_tbl =& bTable::getInstance('users', 'Table');
     $_tbl->load($this->userid);
     $_tbl->bind($data);
     $_tbl->store();
 }