Changeset 1251

Show
Ignore:
Timestamp:
11/05/07 19:53:44 (1 year ago)
Author:
diegoramirez
Message:

Moved from units to mod:

  • groups
  • invite
  • newsclient
  • search
  • xml

Updated htaccess rewrite rules
Some bug fixes to the blog plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/includes_system.php

    r1250 r1251  
    2020        include($CFG->dirroot . "units/profile/main.php"); 
    2121         
    22     // Friend groups 
    23         include($CFG->dirroot . "units/groups/main.php"); 
    24          
    25     // Search 
    26         require($CFG->dirroot . "units/search/main.php"); 
    27          
    28     // Invite-a-friend 
    29         require($CFG->dirroot . "units/invite/main.php"); 
    30          
    3122    // XML parsing 
    32         require($CFG->dirroot . "units/xml/main.php"); 
    33          
    34     // Your Resources 
    35         require($CFG->dirroot . "units/magpie/main.php"); 
    36          
     23        require($CFG->dirroot . "lib/xmllib.php"); 
     24                 
    3725?> 
  • devel/lib/elgglib.php

    r1243 r1251  
    44 * Library of functions for handling input validation  
    55 * and some HTML generation 
    6  * This library is a combination of bits of lib/weblib.php 
     6 *  
     7 * This library incorporates portions of bits of lib/weblib.php 
    78 * and lib/moodlelib.php from moodle 
    89 * http://moodle.org || http://sourceforge.net/projects/moodle 
    9  * Copyright (C) 2001-2003  Martin Dougiamas  http://dougiamas.com  
     10 *  
     11 * @copyright Copyright (C) 2001-2003  Martin Dougiamas  http://dougiamas.com  
     12 * @author Curverider Ltd 
    1013 * @author Martin Dougiamas and many others 
     14 * @link http://elgg.org/ 
    1115 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 
     16 * @package elgg 
     17 * @subpackage elgg.lib 
    1218 */ 
    1319 
     
    373379    //} 
    374380    //called from setup.php, so gettext module hasn't been loaded yet 
    375  
    376         // make sure the session has really terminated  
    377         session_destroy(); 
    378  
    379         redirect($FULLME, '', 1); 
     381    redirect($FULLME, '', 1); 
    380382} 
    381383 
     
    42164218} 
    42174219 
     4220/** 
     4221 *  Returns whether or not the current logged in user has permission to edit 
     4222 *  a resource owned by a given account. 
     4223 *  @param string $objecttype The type of object 
     4224 *  @param int $owner The owning account's ident 
     4225 *  @return boolean $permissions True or false 
     4226 */ 
     4227 
     4228function permissions_check($objecttype, $owner) { 
     4229     
     4230    static $permissions_check; 
     4231     
     4232    if (isset($permissions_check[$objecttype][$owner])) { 
     4233        return $permissions_check[$objecttype][$owner]; 
     4234    } 
     4235     
     4236    if ($allmods = get_list_of_plugins('mod')) { 
     4237        foreach ($allmods as $mod) { 
     4238            $mod_permissions_check = $mod . "_permissions_check"; 
     4239            if (function_exists($mod_permissions_check)) { 
     4240                if ($value = $mod_permissions_check($objecttype, $owner)) { 
     4241                    $permissions_check[$objecttype][$owner] = $value; 
     4242                    return $value; 
     4243                } 
     4244            } 
     4245        } 
     4246    } 
     4247     
     4248    return false; 
     4249     
     4250} 
     4251  
    42184252?> 
  • devel/lib/php-getttext/gettext.inc

    r659 r1251  
    129129        $ret = 0; 
    130130        if (function_exists('setlocale')) // I don't know if this ever happens ;) 
    131            $ret = setlocale($category, $locale); 
     131error_log($categori,$locale);            
     132                $ret = setlocale($category, $locale); 
    132133        if (($ret and $locale == '') or ($ret == $locale)) { 
    133134            $EMULATEGETTEXT = 0; 
  • devel/lib/setup.php

    r990 r1251  
    469469} 
    470470 
     471 
    471472/*** 
    472473 *** init_performance_info() { 
  • devel/lib/templates.php

    r1244 r1251  
    117117        <div style="float: left; width: 70px"><a href="{{profileurl}}">{{usericon}}</a></div> 
    118118        <div style="margin-left: 75px; margin-top: 0px; padding-top: 0px; text-align: left" ><p> 
    119             <span class="userdetails">{{name}}<br /><a href="{{profileurl}}rss/"><img src="{{url}}mod/template/icons/rss.png" alt="RSS" /></a> | <a href="{{profileurl}}tags/">$tags</a> | <a href="{{profileurl}}newsclient/">$resources</a></span></p> 
     119            <span class="userdetails">{{name}}<br /><a href="{{profileurl}}rss/">RSS</a> | <a href="{{profileurl}}tags/">$tags</a> | <a href="{{profileurl}}newsclient/">$resources</a></span></p> 
    120120            <p>{{tagline}}</p> 
    121121            <p>{{lmshosts}}</p> 
     
    447447                                    //'html' => a_href("{$CFG->wwwroot}_admin/", 
    448448                                    //                "Administration")); 
    449                                     'html' => "<li><a href=\"" . $CFG->wwwroot . "_admin/\">" . __gettext("Administration") . "</a></li>"); 
     449                                    'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>"); 
    450450    } 
    451451     
     
    463463                                  'html' => "<li><a href=\"" . $CFG->wwwroot . "login/logout.php\">" . __gettext("Log off") . "</a></li>"); 
    464464    }; 
    465  
    466     if (defined("context") && context == "account") { 
    467         $PAGE->menu_sub[] = array( 
    468                                   'name' => 'user:edit', 
    469                                   'html' => a_href("{$CFG->wwwroot}_userdetails/", 
    470                                                    __gettext("Edit user details"))); 
    471         $PAGE->menu_sub[] = array( 
    472                                   'name' => 'user:icon', 
    473                                   'html' => a_href("{$CFG->wwwroot}_icons/", 
    474                                                    __gettext("Your site picture"))); 
    475     } 
    476  
    477     if (defined("context") && context == "admin" && logged_on && user_flag_get("admin", $_SESSION['userid'])) { 
    478         $PAGE->menu_sub[] = array( 
    479                                   'name' => 'admin', 
    480                                   'html' => a_href("{$CFG->wwwroot}_admin/", 
    481                                                    __gettext("Main"))); 
    482     
    483         $PAGE->menu_sub[] = array( 
    484                                   'name' => 'admin:useradd', 
    485                                   'html' => a_href("{$CFG->wwwroot}_admin/users_add.php", 
    486                                                    __gettext("Add users"))); 
    487  
    488         $PAGE->menu_sub[] = array( 
    489                                   'name' => 'admin:users', 
    490                                   'html' => a_href("{$CFG->wwwroot}_admin/users.php", 
    491                                                    __gettext("Manage users"))); 
    492  
    493         $PAGE->menu_sub[] = array( 
    494                                   'name' => 'admin:users', 
    495                                   'html' => a_href("{$CFG->wwwroot}_admin/users.php?flag=banned", 
    496                                                    __gettext("Banned users"))); 
    497  
    498         $PAGE->menu_sub[] = array( 
    499                                   'name' => 'admin:users', 
    500                                   'html' => a_href("{$CFG->wwwroot}_admin/users.php?flag=admin", 
    501                                                    __gettext("Admin users"))); 
    502  
    503         $PAGE->menu_sub[] = array( 
    504                                   'name' => 'admin:flaggedcontent', 
    505                                   'html' => a_href("{$CFG->wwwroot}_admin/flags.php", 
    506                                                    __gettext("Manage flagged content"))); 
    507     
    508         $PAGE->menu_sub[] = array( 
    509                                   'name' => 'admin:spam', 
    510                                   'html' => a_href("{$CFG->wwwroot}_admin/antispam.php", 
    511                                                    __gettext("Spam control"))); 
    512              
    513     } 
    514465 
    515466 
     
    13301281            if (!empty($template_name)) { 
    13311282                // use a defined style 
    1332                 $result = '<link href="' . $CFG->wwwroot  . '_templates/css.php?template=' . $template_name . '" rel="stylesheet" type="text/css" />' . "\n"; 
     1283                $result = '<link href="' . $CFG->wwwroot  . '_templates/css/' . $template_name. '" rel="stylesheet" type="text/css" />' . "\n"; 
    13331284            } else { 
    13341285                // use whatever's in $template['css'] 
     
    14561407        case "populartags": 
    14571408            $result = ""; 
    1458             if (isset($vars[1])) { 
    1459                 $vars[1] = (int) $vars[1]; 
    1460             } else { 
    1461                 $vars[1] = "20"; 
    1462             } 
    1463             if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit " . $vars[1])) { 
     1409            if ($tags = get_records_sql("SELECT tag, count(ident) as numtags FROM `".$CFG->prefix."tags` WHERE access = 'public' and tag!='' group by tag having numtags > 1 order by ident desc limit 20")) { 
    14641410                $max = 0; 
    14651411                foreach($tags as $tag) { 
  • devel/lib/userlib.php

    r1046 r1251  
    11<?php 
    22 
    3 /** 
    4  * Library of functions for user polling and manipulation. 
    5  * Largely taken from the old /units/users/ 
    6  * Copyright (C) 2004-2006 Ben Werdmuller and David Tosh 
    7  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 
    8  */ 
    9  
    10   
     3    /** 
     4     * Library of functions for user polling and manipulation. 
     5     *  
     6     * @copyright Copyright (C) 2004-2006 Ben Werdmuller and David Tosh 
     7     * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 
     8     * @package elgg 
     9     * @subpackage elgg.lib 
     10     */ 
     11 
    1112// INITIALISATION ////////////////////////////////////////////////////////////// 
    1213 
     
    2627    define('AUTH_MSG_MISSING', __gettext("Either the username or password were not specified. The system could not log you on.")); 
    2728 
    28 // USER INFORMATION RETRIEVAL ////////////////////////////////////////////////// 
    29  
    30     // Given a user ID number, returns the specified field 
    31     // Returns false if the user doesn't exist. 
     29        /** 
     30         * User information value by id 
     31         *  
     32         * Returns a specified field by user id 
     33         *  
     34         * @param string $fieldname the specific field 
     35         * @param integer $user_id the user id 
     36         * @return mixed string if success else false if the user doesn't exist 
     37     * @author Ben WerdMuller <ben@curverider.co.uk> 
     38     */ 
    3239    function user_info($fieldname, $user_id) { 
    3340         
     
    5764    } 
    5865     
    59     // Given a username, returns the specified field 
    60     // Returns false if the user doesn't exist. 
     66    /** 
     67         * User information value by username 
     68         *  
     69         * Returns a specified field by username 
     70         * 
     71         * @param string $fieldname the specific field 
     72         * @param integer $user_id the user id 
     73         * @return mixed string if success else false if the user doesn't exist 
     74     * @author Ben WerdMuller <ben@curverider.co.uk> 
     75     */ 
    6176    function user_info_username($fieldname, $username) { 
    6277         
     
    8196    } 
    8297     
    83     // Gets the type of a particular user 
     98    /** 
     99     * Gets the type of a particular user 
     100     *  
     101     * @param integer $user_id the user id 
     102     * @return mixed string the user type or false if the user doesn't exist 
     103     * @author Ben WerdMuller <ben@curverider.co.uk> 
     104     */ 
    84105    function user_type($user_id) { 
    85          
    86106        return user_info('user_type', $user_id); 
    87          
    88107    } 
    89108     
     
    96115     * @param integer $user_id  The unique ID of the user we want to find the name for. 
    97116     * @return string Returns the user's name, or a blank string if something went wrong (eg the user didn't exist). 
     117     * @author Ben WerdMuller <ben@curverider.co.uk> 
    98118     */ 
    99119    function user_name($user_id) { 
     
    114134     * containing the elements 'html', 'icon' (being the icon ID), 'size', 'owner' and 'url'. 
    115135     * 
    116      * @uses $CFG 
     136     * @todo TODO refactor, separate display code 
     137     * @global CFG global configuration 
    117138     * @param integer $user_id  The unique ID of the user we want to display the icon for. 
    118139     * @param integer $size  The size of the icon we want to display (max: 100). 
    119140     * @param boolean $urlonly  If true, returns the URL of the icon rather than the full HTML. 
    120141     * @return string Returns the icon HTML, or the default icon if something went wrong (eg the user didn't exist). 
     142     * @author Ben WerdMuller <ben@curverider.co.uk> 
    121143     */ 
    122144    function user_icon_html($user_id, $size = 100, $urlonly = false) { 
     
    194216            $currentaccess += 1000; 
    195217        } 
     218error_log($currentaccess); 
    196219             
    197220        return $currentaccess; 
     
    201224    function protect($level, $owner = -1) { 
    202225        global $CFG; 
     226         
     227        error_log($level); 
     228        error_log($owner); 
    203229        if (accesslevel($owner) < $level) { 
    204230            echo '<a href="' . $CFG->wwwroot . '">' . __gettext("Access Denied") . '</a>'; 
     
    209235// NOTIFICATIONS AND MESSAGING ///////////////////////////////////////////////// 
    210236 
    211     // Send a message to a user 
    212      
     237    //  
     238     
     239    /** 
     240     * Send a message to a user 
     241     *  
     242     * @param integer $to the receiving user id 
     243     * @param integer $from the sending user id 
     244     * @param string $message the message body 
     245     * @return boolean 
     246     * @author Ben WerdMuller <ben@curverider.co.uk> 
     247     * @author Misja Hoebe <misja@curverider.co.uk> 
     248     */ 
    213249    function message_user($to, $from, $title, $message) { 
    214250         
     
    224260            $email_from->email = $CFG->noreplyaddress; 
    225261            $email_from->name = $CFG->sitename; 
    226              
    227             if ($email_to = get_record_sql("select * from ".$CFG->prefix."users where ident = " . $to)) { 
    228              
     262 
     263            if ($email_to = get_record('users', 'ident', $to)) 
     264            { 
    229265                if (!email_to_user($email_to,$email_from,$title,$message . "\n\n\n" . __gettext("You cannot reply to this message by email."))) { 
    230266                    $messages[] = __gettext("Failed to send email. An unknown error occurred."); 
     
    242278         
    243279        if (!insert_record('messages',$m)) { 
     280            trigger_error(__FUNCTION__.": Failed to send message from $from to $to. An unknown error occurred.", E_ERROR); 
     281             
    244282            $messages[] = __gettext("Failed to send message. An unknown error occurred."); 
    245         } 
    246          
    247     } 
    248      
    249     // Get user $user_id's messages; optionally limit the number or the timeframe 
    250      
     283        } else { 
     284            plugin_hook("message", "publish", $m); 
     285            return true; 
     286        } 
     287         
     288    } 
     289     
     290    /** 
     291     * Get user's messages 
     292     *  
     293     * Get the user's messages, optionally limit the number or the timeframe 
     294     *  
     295     * @param integer $user_id the user id 
     296     * @param integer $number the number of messages to retrieve 
     297     * @param integer $timeframe the timeframe 
     298     * @return mixed an ADODB RecordSet object with the results or false 
     299     * @author Ben WerdMuller <ben@curverider.co.uk> 
     300     */ 
    251301    function get_messages($user_id, $number = null, $timeframe = null) { 
    252302         
     
    266316    } 
    267317     
    268     // Return the basic HTML for a message (given its database row), where the  
    269     // title is a heading 2 and the body is in a paragraph. 
    270      
     318    /** 
     319     * Return the basic HTML for a message (given its database row),  
     320     * where the title is a heading 2 and the body is in a paragraph. 
     321     *  
     322     * @param string $message the message body 
     323     * @return string HTML output 
     324     * @todo TODO refactor, separate display and logic 
     325     * @author Ben WerdMuller <ben@curverider.co.uk> 
     326     */     
    271327    function display_message($message) { 
    272328         
     
    300356         
    301357    } 
    302  
    303     // Send a notification to a user, both using the notifications table and 
    304     // - potentially - email, depending on a user's preferences 
    305      
     358         
     359    /** 
     360     * Send a notification to a user 
     361     *  
     362     * Could be a notifications or email,  
     363     * depending on a user's preferences 
     364     *  
     365     * @param integer $user_id the user id 
     366     * @param string $title the message title 
     367     * @param string $message the message body 
     368     * @return boolean 
     369     * @todo TODO fix return type 
     370     * @author Ben WerdMuller <ben@curverider.co.uk> 
     371     */     
    306372    function notify_user($user_id, $title, $message) { 
    307373         
    308374        message_user($user_id, -1, $title, $message); 
    309          
    310     } 
    311      
    312     // Mark a user's messages as read 
    313      
     375    } 
     376     
     377    /** 
     378     * Mark a user's messages as read 
     379     *  
     380     * @param integer $user_id the user's id 
     381     * @return mixed An ADODB RecordSet object with the results from the SQL call or false. 
     382     * @author Ben WerdMuller <ben@curverider.co.uk> 
     383     */ 
    314384    function messages_read($user_id) { 
    315385         
    316386        global $CFG; 
    317         //execute_sql("update ".$CFG->prefix."messages set status = 'read' where to_id = $user_id",false); 
    318         set_field('messages', 'status', 'read', 'to_id', $user_id); 
    319          
    320     } 
    321      
    322     // Cleanup messages - this should be relatively temporary 
    323      
     387 
     388        $result = set_field('messages', 'status', 'read', 'to_id', $user_id); 
     389         
     390        return $result; 
     391    } 
     392     
     393    /** 
     394     * Clean up user messages 
     395     *  
     396     * @global CFG global configuration 
     397     * @param integer $older_than 
     398     * @return boolean 
     399     * @todo TODO this should be relatively temporary (Ben?) 
     400     * @author Ben WerdMuller <ben@curverider.co.uk> 
     401     * @author Misja Hoebe <misja@curverider.co.uk> 
     402     */ 
    324403    function cleanup_messages($older_than) { 
    325404      
    326         global $CFG, $messages; 
    327         execute_sql("delete from ".$CFG->prefix."messages where posted < " . $older_than,false); 
    328          
    329             
     405        global $CFG; 
     406         
     407        $result = execute_sql("delete from ".$CFG->prefix."messages where posted < " . $older_than,false); 
     408         
     409        return $result; 
    330410    } 
    331411     
    332412// STATISTICS ////////////////////////////////////////////////////////////////// 
    333413 
    334     // Count number of users 
    335     // Optional: the user_type (eg 'person') and the minimum last time they 
    336     // performed an action 
    337      
     414    /** 
     415     * Count number of users 
     416     *  
     417     * @global CFG global configuration  
     418     * @param string $type the user_type (eg 'person') 
     419     * @param integer $last_action the minimum last time they performed an action 
     420     * @return integer the number of users 
     421     * @author Ben WerdMuller <ben@curverider.co.uk> 
     422     */ 
    338423    function count_users($type = '', $last_action = 0) { 
    339424         
     
    367452     * Delete a user. 
    368453     * 
    369      * @uses $CFG 
     454     * @global CFG global configuration 
    370455     * @param integer $user_id  The unique ID of the user to delete. 
    371456     * @return true|false Returns true if the user was deleted; false otherwise. 
    372      */ 
    373      function user_delete($user_id) { 
    374  
    375          global $CFG; 
    376  
    377          // Verify that the user exists 
    378          if ($user = get_record_sql("select * from {$CFG->prefix}users where ident = {$user_id}")) { 
     457     * @author Ben WerdMuller <ben@curverider.co.uk> 
     458     */ 
     459    function user_delete($user_id) { 
     460 
     461        global $CFG; 
     462 
     463        // Verify that the user exists 
     464        if ($user = get_record_sql("select * from {$CFG->prefix}users where ident = {$user_id}")) { 
    379465              
    380             // Call the event hook for all plugins to do their worst with the user's data 
    381             $user = plugin_hook("user","delete",$user); 
     466            // Call the event hook for all plugins to do their worst with the user's data 
     467            $user = plugin_hook("user","delete",$user); 
    382468              
    383             // If all went well ... 
    384             if (!empty($user)) { 
     469            // If all went well ... 
     470            if (!empty($user)) { 
    385471                  
    386                 // Remove any icons and icon folders 
    387                 if ($icons = get_records_sql("select * from {$CFG->prefix}icons where owner = {$user->ident}")) { 
    388                     foreach($icons as $icon) { 
    389                         $filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/" . $icon->filename; 
    390                         @unlink($filepath); 
    391                    
    392                     @rmdir($filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/"); 
    393                
     472                // Remove any icons and icon folders 
     473                if ($icons = get_records_sql("select * from {$CFG->prefix}icons where owner = {$user->ident}")) { 
     474                    foreach($icons as $icon) { 
     475                        $filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/" . $icon->filename; 
     476                        @unlink($filepath); 
     477                   
     478                    @rmdir($filepath = $CFG->dataroot . "icons/" . substr($user->username,0,1) . "/" . $user->username . "/"); 
     479               
    394480                  
    395                 // Remove the user from the database! 
    396                 delete_records("users","ident",$user->ident); 
    397                 delete_records("user_flags","user_id",$user->ident); 
    398                 delete_records("messages","to_id",$user->ident); 
    399                 delete_records("messages","from_id",$user->ident); 
    400                 return true; 
    401  
    402            
     481                // Remove the user from the database! 
     482                delete_records("users","ident",$user->ident); 
     483                delete_records("user_flags","user_id",$user->ident); 
     484                delete_records("messages","to_id",$user->ident); 
     485                delete_records("messages","from_id",$user->ident); 
     486                return true; 
     487 
     488           
    403489              
    404              return false; 
    405          } 
    406  
    407      } 
    408      
     490            return false; 
     491        } 
     492    } 
     493     
     494    /** 
     495     * Get the user's friends 
     496     *  
     497     * @global CFG global configuration 
     498     * @param integer $user_id the user id 
     499     * @return mixed a result set packed in an array or empty 
     500     * @author Misja Hoebe <misja@curverider.co.uk> 
     501     */ 
     502    function user_friends($user_id) { 
     503        global $CFG; 
     504         
     505        $result = get_records_sql('SELECT f.friend AS user_id,u.name FROM '.$CFG->prefix.'friends f 
     506                                   JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
     507                                   WHERE f.owner = ? ORDER BY u.name', array($user_id)); 
     508         
     509        return $result; 
     510    } 
     511 
     512    /** 
     513     * Get the users who have marked this user as a friend (sorted by the friends latest activity) 
     514     *  
     515     * @global CFG global configuration 
     516     * @param integer $user_id the user id 
     517     * @return mixed a result set packed in an array or empty 
     518     * @author Misja Hoebe <misja@curverider.co.uk> 
     519     */ 
     520    function user_friends_of($user_id) { 
     521        global $CFG; 
     522         
     523        $result = get_records_sql('SELECT u.ident, u.username FROM '.$CFG->prefix.'friends f 
     524                                  JOIN '.$CFG->prefix.'users u ON u.ident = f.owner 
     525                                  WHERE friend = ? AND u.user_type = ? order by u.last_action desc', array($user_id, 'person')); 
     526         
     527        return $result; 
     528    } 
     529     
     530    /** 
     531     * Add the a user to a friends list 
     532     *  
     533     * @param integer $user_id the user id 
     534     * @param integer $friend_id the friend id 
     535     * @param boolean $moderate is this a moderated friendship request 
     536     * @param string  $type the type, used for being able to reuse functionality for communities  
     537     * @return boolean 
     538     * @author Misja Hoebe <misja@curverider.co.uk> 
     539     */ 
     540    function user_friend_add($user_id, $friend_id, $moderate = false, $type = 'friendship') { 
     541        if (empty($user_id) || empty($friend_id)) { 
     542            trigger_error(__FUNCTION__.": invalid arguments (user id: $user_id, friend id: $friend_id)", E_ERROR); 
     543        } 
     544         
     545        if (record_exists('friends', 'owner', $user_id, 'friend', $friend_id)) { 
     546            $obj         = new StdClass; 
     547            $obj->owner  = $user_id; 
     548            $obj->friend = $friend_id; 
     549 
     550            // Type check 
     551            if ($type != 'friendship' || $type != 'membership') { 
     552                trigger_error("user_friend_add(): only type 'friendship' or 'membership' is accepted but '$type' was passed.", E_ERROR); 
     553                return false; 
     554            } 
     555             
     556            if ($moderation == false) { 
     557                // Regular friendship/membership 
     558                if (insert_record('friends', $obj)) { 
     559                    plugin_hook($type, "publish", $obj); 
     560                    return true; 
     561                } else { 
     562                    return false;    
     563                } 
     564            } else { 
     565                // Moderated friendship/membership 
     566                if (insert_record('friends_requests', $obj)) { 
     567                    plugin_hook($type, "request", $obj); 
     568                    return true; 
     569                } else { 
     570                    return false; 
     571                } 
     572            } 
     573        } else { 
     574            return false; 
     575        } 
     576    } 
     577 
     578    /** 
     579     * Delete a user from a friends list 
     580     *  
     581     * @param integer $user_id the user id 
     582     * @param integer $friend_id the friend id 
     583     * @return mixed an ADODB RecordSet object with the results or false 
     584     * @author Misja Hoebe <misja@curverider.co.uk> 
     585     */ 
     586    function user_friend_delete($user_id, $friend_id) { 
     587        if (empty($user_id) || empty($community_id)) { 
     588            trigger_error(__FUNCTION__.": invalid arguments (user id: $user_id, friend id: $friend_id)", E_ERROR); 
     589        } 
     590         
     591        $result = delete_records('friends', 'owner', $user_id, 'friend', $friend_id); 
     592         
     593        if ($result != false) { 
     594            plugin_hook("friendship", "delete", $result); 
     595        } 
     596 
     597        return $result; 
     598    } 
    409599?> 
  • devel/mod/blog/README

    r1077 r1251  
    77 
    88POSTS_PER_PAGE (default value: 10) 
    9        To configure the max number of posts per page in (view blog, archive, friends posts, 
    10        interesting posts, all posts) you can change the constant 'POSTS_PER_PAGE' in 
    11        'blog/lib/weblogs_init.php'. 
     9  To configure the max number of posts per page in (view blog, archive, friends posts, 
     10  interesting posts, all posts) you can change the constant 'POSTS_PER_PAGE' in 
     11  'blog/lib/weblogs_init.php'. 
    1212 
    1313Extension points 
     
    2020------------------ 
    2121 
    22 display:icon:select 
    23         File(s): 
    24                 - blog/lib/weblogs_posts_add.php 
    25                 - blog/lib/weblogs_posts_edit.php 
    26         Action: 
    27                 Allow plugins to add an icon selection box 
    28         Know implementations: 
    29                 The 'posticon' plug-in 
     22weblogs:posts:add:fields:before 
     23  File(s): 
     24    - blog/lib/weblogs_posts_add.php 
     25    - blog/lib/weblogs_posts_edit.php 
     26  Action: 
     27    Allow plugins to add extra fields before the post textarea 
     28    and behind the 'extrafield' field 
    3029</