├── README.rdoc ├── joomla_1.5 ├── plugins │ ├── category_list.php │ ├── category_list.xml │ ├── content_create.php │ ├── content_create.xml │ ├── events_create.php │ ├── events_create.xml │ ├── events_delete.php │ ├── events_delete.xml │ ├── events_list.php │ ├── events_list.xml │ ├── events_update.php │ ├── events_update.xml │ ├── group_announcement_create.php │ ├── group_announcement_create.xml │ ├── group_announcement_delete.php │ ├── group_announcement_delete.xml │ ├── group_announcement_list.php │ ├── group_announcement_list.xml │ ├── group_announcement_update.php │ ├── group_announcement_update.xml │ ├── group_discussion_create.php │ ├── group_discussion_create.xml │ ├── group_discussion_delete.php │ ├── group_discussion_delete.xml │ ├── group_discussion_list.php │ ├── group_discussion_list.xml │ ├── group_discussion_replies_create.php │ ├── group_discussion_replies_create.xml │ ├── group_discussion_replies_delete.php │ ├── group_discussion_replies_delete.xml │ ├── group_discussion_replies_list.php │ ├── group_discussion_replies_list.xml │ ├── group_discussion_replies_update.php │ ├── group_discussion_replies_update.xml │ ├── group_discussion_update.php │ ├── group_discussion_update.xml │ ├── group_list.php │ ├── group_list.xml │ ├── group_member_list.php │ ├── group_member_list.xml │ ├── group_members_create.php │ ├── group_members_create.xml │ ├── group_members_delete.php │ ├── group_members_delete.xml │ ├── search.php │ ├── search.xml │ ├── user_create.php │ ├── user_create.xml │ ├── user_delete.php │ ├── user_delete.xml │ ├── user_list.php │ ├── user_list.xml │ ├── user_update.php │ ├── user_update.xml │ ├── wall_post_create.php │ ├── wall_post_create.xml │ ├── wall_post_delete.php │ ├── wall_post_delete.xml │ ├── wall_post_list.php │ ├── wall_post_list.xml │ ├── wall_post_update.php │ └── wall_post_update.xml ├── samples │ ├── RESTclient.php │ ├── css │ │ ├── hand.css │ │ ├── handheld.css │ │ ├── iphone.css │ │ ├── web.css │ │ ├── web.css~ │ │ └── web_bac.css │ ├── functions.php │ ├── group_create.html │ ├── group_create.php │ ├── img │ │ ├── .DS_Store │ │ └── button.png │ └── user_crud.php └── server │ ├── .htaccess │ ├── classes.php │ ├── includes │ ├── application.php │ ├── custom_json.php │ ├── defines.php │ ├── framework.php │ └── index.html │ └── index.php └── joomla_1.6 ├── plugins ├── group_create │ ├── group_create.php │ └── group_create.xml ├── group_discussion_create │ ├── group_discussion_create.php │ └── group_discussion_create.xml ├── group_discussion_list │ ├── group_discussion_list.php │ └── group_discussion_list.xml ├── group_list │ ├── group_list.php │ └── group_list.xml ├── user_create │ ├── user_create.php │ └── user_create.xml └── user_list │ ├── user_list.php │ └── user_list.xml └── server ├── cache └── index.html ├── classes.php ├── includes ├── application.php ├── custom_json.php ├── defines.php ├── framework.php └── index.html └── index.php /README.rdoc: -------------------------------------------------------------------------------- 1 | = Joomla REST API 2 | 3 | This implementaion of the Joomla REST API is no longer used, supported, maintained or recommended. Please use the newer com_api which can be fond here 4 | 5 | https://github.com/techjoomla/com_api 6 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/category_list.php: -------------------------------------------------------------------------------- 1 | createnewcatlist(); 38 | 39 | return $id; 40 | } 41 | 42 | 43 | function createnewcatlist() 44 | { 45 | 46 | 47 | $database = &JFactory::getDBO(); 48 | $qer = "SELECT * FROM #__categories"; 49 | $database->setQuery($qer); 50 | $result = $database->loadObjectList(); 51 | header('Content-type: application/json'); 52 | foreach($result as $res) 53 | { 54 | if(is_numeric($res->section)){ 55 | $qer = "SELECT title FROM #__sections WHERE id=".$res->section; 56 | $database->setQuery($qer); 57 | $sectionname = $database->loadResult(); 58 | ?> 59 | { 60 | "sectionid": "section ;?>", 61 | "categoryid": "id; ?>", 62 | "sectionid": "", 63 | "categoryname": "title; ?>" 64 | 65 | } 2 | 3 | Create Catlist - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create catlist plugin 12 | 13 | category_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/content_create.php: -------------------------------------------------------------------------------- 1 | createnewcontent( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewcontent( $data ) 47 | { 48 | 49 | //jimport('joomla.user.helper'); 50 | //require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 51 | 52 | $error_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | 56 | 57 | if($data['title']=='' || strlen($data['title'])=='0') 58 | { 59 | $validated = false; 60 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"Title cannot be blank"); 61 | } 62 | if($data['sectionid']=='' || $data['sectionid']==0) 63 | { 64 | $validated = false; 65 | $error_messages[] = array("id"=>1,"fieldname"=>"sectionid","message"=>"Sectionid cannot be blank"); 66 | } 67 | if($data['introtext']=='' || strlen($data['introtext'])==0) 68 | { 69 | $validated = false; 70 | $error_messages[] = array("id"=>1,"fieldname"=>"introtext","message"=>"Introtext cannot be blank"); 71 | } 72 | if($data['catid']=='' || $data['catid']==0) 73 | { 74 | $validated = false; 75 | $error_messages[] = array("id"=>1,"fieldname"=>"catid","message"=>"Catid cannot be blank"); 76 | } 77 | 78 | $db = &JFactory::getDBO(); 79 | $row = new stdClass; 80 | $row->id = NULL; 81 | $row->title = $data['title']; 82 | $row->introtext = $data['introtext']; 83 | $row->alias = str_replace(" ", "-", $row->title); 84 | $row->fulltext = $data['fulltext']; 85 | $row->state = $data['state']; 86 | $row->sectionid = $data['sectionid']; 87 | $row->catid = $data['catid']; 88 | $row->created_by = $data['creared_by']; 89 | $row->created = date('Y-m-d H:i:s'); 90 | if( true == $validated ) 91 | { 92 | if(!$db->insertObject( '#__content', $row, 'id' )) 93 | { 94 | 95 | $error_messages[] = array("id"=>1,"fieldname"=>"createdby","message"=>"Content not inserted.please check fields in request"); 96 | return false; 97 | } 98 | 99 | } 100 | 101 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 102 | { 103 | $res= array(); 104 | foreach( $error_messages as $key => $error_message ) 105 | { 106 | $res[] = $error_message; 107 | 108 | } 109 | 110 | $response = array("id" => 0,'errors'=>$res); 111 | } else { 112 | $response = array('id' => $row->id);; 113 | } 114 | 115 | return $response; 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/content_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Content - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create content plugin 12 | 13 | content_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Event - Example 4 | Joomla! Project 5 | jan 2011 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create event plugin 12 | 13 | events_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_delete.php: -------------------------------------------------------------------------------- 1 | deleteevents( $data ); 36 | return $id; 37 | } 38 | 39 | function deleteevents( $data ) 40 | { 41 | jimport('joomla.user.helper'); 42 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 43 | $error_messages = array(); 44 | $response = NULL; 45 | $validated = true; 46 | 47 | // Get the configuration object. 48 | CFactory::load( 'libraries' , 'activities' ); 49 | CFactory::load( 'helpers' , 'owner' ); 50 | CFactory::load( 'models' , 'events' ); 51 | $config = & CFactory::getConfig(); 52 | CFactory::load('helpers', 'limits' ); 53 | CFactory::load( 'libraries' , 'apps' ); 54 | 55 | if($data['eventid']== "" || $data['eventid']== "0") 56 | { 57 | $validated = false; 58 | $error_messages[] = array("id"=>1,"fieldname"=>"eventid","message"=>"Eventid cannot be blank"); 59 | } 60 | 61 | if( true == $validated ) 62 | { 63 | // Bind the data with the table first 64 | $model =& CFactory::getModel( 'events' ); 65 | $event =& JTable::getInstance( 'Event' , 'CTable' ); 66 | $event->load( $data['eventid'] ); 67 | 68 | 69 | if( $event->delete() ) 70 | { 71 | 72 | jimport( 'joomla.filesystem.file' ); 73 | 74 | } 75 | 76 | $event->deleteAllMembers(); 77 | CFactory::load ( 'libraries', 'activities' ); 78 | } 79 | 80 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 81 | { 82 | $res= array(); 83 | foreach( $error_messages as $key => $error_message ) 84 | { 85 | $res[] = $error_message; 86 | 87 | } 88 | 89 | $response = array("id" => 0,'errors'=>$res); 90 | } else { 91 | $response = array('id' => $event->id);; 92 | } 93 | 94 | return $response; 95 | 96 | 97 | 98 | } 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Event - Example 4 | Joomla! Project 5 | jan 2011 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete events plugin 12 | 13 | events_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_list.php: -------------------------------------------------------------------------------- 1 | = "'.$startdt. '" AND date(e.created) <= "'.$enddt.'"'; 76 | $flag = false; 77 | } 78 | 79 | $where[]= "e.creator = u.id AND e.published = 1 "; 80 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 81 | 82 | if(!$flag) 83 | { 84 | $qry = "SELECT e.id AS eventid,e.catid,e.title AS eventtitle,e.description,e.location,e.startdate,e.enddate,e.created,e.creator 85 | FROM #__community_events As e, #__users AS u 86 | {$where} LIMIT {$start}, {$limit}"; 87 | $db->setQuery($qry); 88 | $eventrec = $db->loadAssocList(); 89 | $eventcount = count($eventrec); 90 | 91 | if($eventcount) { 92 | $eventlist = array('size' => $eventcount,'records'=>$eventrec); 93 | }else{ 94 | $eventlist = array('size' => 0); 95 | } 96 | 97 | }else{ 98 | $eventlist=false; 99 | } 100 | 101 | if(!$eventlist){ 102 | $eventlisterror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Group id is not available'); 103 | $eventlisterror[] = array("id"=>1,"fieldname"=>"groupname",'message'=>'Group Name is not available'); 104 | $eventlisterror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 105 | $eventlisterror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 106 | $eventlisterror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 107 | 108 | $eventlist = array('size' => -1,'errors'=>$eventlisterror); 109 | } 110 | 111 | return $eventlist; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Events List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an Events list plugin 12 | 13 | events_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_update.php: -------------------------------------------------------------------------------- 1 | updateevents( $data ); 36 | return $id; 37 | } 38 | 39 | function updateevents( $data ) 40 | { 41 | 42 | jimport('joomla.user.helper'); 43 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 44 | $db = &JFactory::getDBO(); 45 | $error_messages = array(); 46 | $response = NULL; 47 | $validated = true; 48 | $config = & CFactory::getConfig(); 49 | CFactory::load('helpers', 'limits' ); 50 | CFactory::load( 'libraries' , 'apps' ); 51 | 52 | if( "" == $data['eventid'] || 0 == strlen( $data['eventid'] )) 53 | { 54 | $validated = false; 55 | $error_messages[] = array("id"=>1,"fieldname"=>"eventid","message"=>"eventid cannot be blank"); 56 | } 57 | 58 | if( "" == $data['creator'] || 0 == strlen( $data['creator'] )) 59 | { 60 | $validated = false; 61 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"creator cannot be blank"); 62 | } 63 | if( "" == $data['catid'] || 0 == strlen( $data['catid'] )) 64 | { 65 | $validated = false; 66 | $error_messages[] = array("id"=>1,"fieldname"=>"catid","message"=>"catid cannot be blank"); 67 | } 68 | if( $data['title']=="") { 69 | $validated = false; 70 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"title cannot be blank"); 71 | } 72 | 73 | if( $data['location']=="") { 74 | $validated = false; 75 | $error_messages[] = array("id"=>1,"fieldname"=>"location","message"=>"location cannot be blank"); 76 | } 77 | if( $data['allowinvite']=="") { 78 | $validated = false; 79 | $error_messages[] = array("id"=>1,"fieldname"=>"allowinvite","message"=>"allowinvite cannot be blank"); 80 | } 81 | if( true == $validated ) { 82 | 83 | // Bind the data with the table first 84 | $event = JTable::getInstance( 'Event' , 'CTable' ); 85 | $event->set( 'id', $data['eventid'] ); 86 | $event->set( 'title', $data['title'] ); 87 | $event->set( 'description', $data['description'] ); 88 | $event->set( 'location', $data['location'] ); 89 | $event->set( 'ticket', $data['ticket'] ); 90 | $event->set( 'catid', $data['catid']); 91 | $event->set( 'allowinvite', $data['allowinvite']); 92 | $event->set( 'creator', $data['creator']); 93 | $event->set( 'created', gmdate( 'Y-m-d H:i:s' )); 94 | $event->set( 'confirmedcount', 1); 95 | 96 | if($data['permission']==""){ 97 | $event->set( 'permission', 0); 98 | }else{ 99 | $event->set( 'permission', $data['permission']); 100 | } 101 | if($data['startdate']==""){ 102 | $event->set( 'startdate', gmdate( 'Y-m-d H:i:s' )); 103 | }else{ 104 | $event->set( 'startdate', $data['startdate'] ); 105 | } 106 | if($data['enddate']==""){ 107 | $event->set( 'enddate', gmdate( 'Y-m-d H:i:s' )); 108 | }else{ 109 | $event->set( 'enddate', $data['enddate'] ); 110 | } 111 | $query = "SELECT id FROM #__users WHERE id =".$data['creator']; 112 | $db->setQuery($query); 113 | $isowner = $db->LoadResult(); 114 | // we here save the group 1st, else the group->id will be missing and causing the member connection and activities broken. 115 | if(!$isowner){ 116 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"Invalid creator id. Update 'creator' field in request"); 117 | }else{ 118 | $event->store(); 119 | } 120 | 121 | 122 | if(!$isowner){ 123 | 124 | }else{ 125 | $event_members = new stdClass(); 126 | $event_members->eventid = $data['eventid']; 127 | $event_members->memberid = $data['creator']; 128 | $db->updateObject( '#__community_events_members' , $event_members, 'eventid'); 129 | 130 | } 131 | } 132 | 133 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 134 | { 135 | $res= array(); 136 | foreach( $error_messages as $key => $error_message ) 137 | { 138 | $res[] = $error_message; 139 | 140 | } 141 | 142 | $response = array("id" => 0,'errors'=>$res); 143 | 144 | 145 | } else { 146 | $response = array('id' => $event->id); 147 | } 148 | 149 | return $response; 150 | 151 | 152 | } 153 | 154 | 155 | } 156 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/events_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Update Event - Example 4 | Joomla! Project 5 | jan 2011 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an update events plugin 12 | 13 | events_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_create.php: -------------------------------------------------------------------------------- 1 | createnewgroupannouncement( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewgroupannouncement( $data ) 47 | { 48 | 49 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 50 | require_once( JPATH_SITE .'/libraries/joomla/filesystem/folder.php'); 51 | 52 | CFactory::load( 'libraries' , 'apps' ); 53 | $error_messages = array(); 54 | $response = NULL; 55 | $validated = true; 56 | 57 | 58 | if( "" == $data['createdby'] || 0 == $data['createdby']) { 59 | $validated = false; 60 | $error_messages[] = array("id"=>1,"fieldname"=>"createdby","message"=>"Createdby cannot be blank"); 61 | } 62 | 63 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 64 | $validated = false; 65 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 66 | } 67 | if( "" == $data['title'] || 0 == strlen( $data['title'] )) { 68 | $validated = false; 69 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"Title cannot be blank"); 70 | } 71 | if( "" == $data['message'] || 0 == strlen( $data['message'] )) { 72 | $validated = false; 73 | $error_messages[] = array("id"=>1,"fieldname"=>"message","message"=>"Message cannot be blank"); 74 | } 75 | 76 | // get user object. 77 | $user =& JFactory::getUser(); 78 | $user->load( $data['createdby'] ); 79 | 80 | // get group object. 81 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 82 | $group->load( $data['groupid'] ); 83 | 84 | 85 | if( $user->id != $group->ownerid ) { 86 | $validated = false; 87 | $error_messages[] = array("id"=>1,"fieldname"=>"createdby and groupid","message"=>"Mismatched the user id and group owner id.Check 'createdby and groupid' fields in request"); 88 | 89 | } 90 | else{ 91 | if( true == $validated ) 92 | { 93 | // Get variables from data array. 94 | 95 | $bulletin =& JTable::getInstance( 'Bulletin' , 'CTable' ); 96 | $bulletin->title = $data['title']; 97 | $bulletin->message = $data['message']; 98 | $validated = true; 99 | $bulletin->groupid = $data['groupid']; 100 | $bulletin->date = gmdate( 'Y-m-d H:i:s' ); 101 | $bulletin->created_by = $data['createdby']; 102 | if($data['published']==""){ 103 | $bulletin->published = 1; 104 | }else{ 105 | $bulletin->published = $data['published']; 106 | } 107 | 108 | $bulletin->store(); 109 | 110 | 111 | } 112 | } 113 | 114 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 115 | $res= array(); 116 | foreach( $error_messages as $key => $error_message ) 117 | { 118 | $res[] = $error_message; 119 | 120 | } 121 | 122 | $response = array("id" => 0,'errors'=>$res); 123 | } else { 124 | $response = array('id' => $bulletin->id); 125 | } 126 | 127 | return $response; 128 | 129 | 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group Announcement- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group announcement plugin 12 | 13 | group_announcement_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_delete.php: -------------------------------------------------------------------------------- 1 | deletegroupannouncement( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function deletegroupannouncement( $data ) 47 | { 48 | 49 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 50 | require_once( JPATH_SITE .'/libraries/joomla/filesystem/folder.php'); 51 | 52 | CFactory::load( 'libraries' , 'apps' ); 53 | $error_messages = array(); 54 | $response = NULL; 55 | $validated = true; 56 | 57 | 58 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 59 | $validated = false; 60 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 61 | } 62 | if($data['bulletinid']=="" || 0 == $data['bulletinid']) 63 | { 64 | $validated = false; 65 | $error_messages[] = array("id"=>1,"fieldname"=>"bulletinid","message"=>"Bulletinid cannot be blank"); 66 | } 67 | $user =& JFactory::getUser(); 68 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 69 | $group->id = $data['groupid']; 70 | 71 | if( true == $validated ) 72 | { 73 | $bulletin =& JTable::getInstance( 'Bulletin' , 'CTable' ); 74 | $bulletin->id = $data['bulletinid']; 75 | $bulletin->groupid = $data['groupid']; 76 | $validated = true; 77 | 78 | if( true == empty( $bulletin->id )) 79 | { 80 | $validated = false; 81 | $error_messages[] = array("id"=>1,"fieldname"=>"bulletinid","message"=>"Invalid bulletin id. Check 'bulletinid' field in request"); 82 | 83 | } 84 | CFactory::load( 'helpers' , 'owner' ); 85 | CFactory::load( 'models' , 'bulletins' ); 86 | 87 | $groupsModel =& CFactory::getModel( 'groups' ); 88 | $bulletin =& JTable::getInstance( 'Bulletin' , 'CTable' ); 89 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 90 | $group->load( $groupid ); 91 | $bulletin->id = $data['bulletinid']; 92 | $bulletin->groupid = $data['groupid']; 93 | 94 | if( $bulletin->delete() ) 95 | { 96 | 97 | //add user points 98 | CFactory::load( 'libraries' , 'userpoints' ); 99 | CUserPoints::assignPoint('group.news.remove'); 100 | 101 | } 102 | 103 | } 104 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 105 | { 106 | $res= array(); 107 | foreach( $error_messages as $key => $error_message ) 108 | { 109 | $res[] = $error_message; 110 | 111 | } 112 | 113 | $response = array("id" => 0,'errors'=>$res); 114 | } else { 115 | $response = array('id' => $bulletin->id); 116 | } 117 | 118 | return $response; 119 | 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Group Announcement- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete group announcement plugin 12 | 13 | group_announcement_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_list.php: -------------------------------------------------------------------------------- 1 | Quote($group_id); 66 | $flag = false; 67 | } 68 | 69 | if ($user_id) { 70 | $where[] = 'w.created_by = ' . $db->Quote($user_id); 71 | $flag = false; 72 | } 73 | 74 | if ($username) { 75 | $where[] = "u.username LIKE '%".$username."%'"; 76 | $flag = false; 77 | } 78 | 79 | if($startdt && $enddt){ 80 | $where[] = ' date(w.date) >= "'.$startdt. '" AND date(w.date) <= "'.$enddt.'"'; 81 | $flag = false; 82 | } 83 | 84 | $where[]= " w.created_by = u.id AND w.published = 1 "; 85 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 86 | 87 | if(!$flag) 88 | { 89 | $qry = "SELECT w.id AS announcementid,w.groupid AS groupid,w.created_by AS userid,w.title,w.message,w.date 90 | FROM #__community_groups_bulletins As w, #__users AS u 91 | {$where} LIMIT {$start}, {$limit}"; 92 | $db->setQuery($qry); 93 | $annorec = $db->loadAssocList(); 94 | $annocount = count($annorec); 95 | 96 | if($annocount) { 97 | $announcements = array('size' => $annocount,'records'=>$annorec); 98 | }else{ 99 | $announcements = array('size' => 0); 100 | } 101 | 102 | }else{ 103 | $announcements=false; 104 | } 105 | 106 | if(!$announcements){ 107 | $announcementserror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Announcement id is not available'); 108 | $announcementserror[] = array("id"=>1,"fieldname"=>"groupid",'message'=>'Group id is not available'); 109 | $announcementserror[] = array("id"=>1,"fieldname"=>"userid",'message'=>'Userid is not available'); 110 | $announcementserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 111 | $announcementserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 112 | $announcementserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 113 | 114 | $announcements = array('size' => -1,'errors'=>$announcementserror); 115 | } 116 | 117 | return $announcements; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group Announcement List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group announcement list plugin 12 | 13 | group_announcement_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_update.php: -------------------------------------------------------------------------------- 1 | updategroupannouncement( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function updategroupannouncement( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | require_once( JPATH_SITE .'/libraries/joomla/filesystem/folder.php'); 50 | 51 | CFactory::load( 'libraries' , 'apps' ); 52 | $error_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | 56 | /*if( 0 == sizeof( $data )) { 57 | $validated = false; 58 | $error_messages[] = 'Fail: Faild to load request data.'; 59 | }*/ 60 | 61 | if( "" == $data['createdby'] || 0 == strlen( $data['createdby'] )) { 62 | $validated = false; 63 | $error_messages[] = array("id"=>1,"fieldname"=>"createdby","message"=>"Createdby cannot be blank"); 64 | } 65 | if( "" == $data['bulletinid'] || 0 == strlen( $data['bulletinid'] )) { 66 | $validated = false; 67 | $error_messages[] = array("id"=>1,"fieldname"=>"bulletinid","message"=>"Bulletinid cannot be blank"); 68 | } 69 | if( "" == $data['groupid'] || 0 == strlen( $data['groupid'] )) { 70 | $validated = false; 71 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 72 | } 73 | if( "" == $data['title'] || 0 == strlen( $data['title'] )) { 74 | $validated = false; 75 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"Title cannot be blank"); 76 | } 77 | if( "" == $data['message'] || 0 == strlen( $data['message'] )) { 78 | $validated = false; 79 | $error_messages[] = array("id"=>1,"fieldname"=>"message","message"=>"Message cannot be blank"); 80 | } 81 | 82 | // get user object. 83 | $user =& JFactory::getUser(); 84 | $user->load( $data['createdby'] ); 85 | 86 | // get group object. 87 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 88 | $group->load( $data['groupid'] ); 89 | 90 | 91 | if( $user->id != $group->ownerid ) { 92 | $validated = false; 93 | 94 | $error_messages[] = array("id"=>1,"fieldname"=>"createdby and groupid","message"=>"Mismatched the user id and group owner id.Check 'createdby and groupid' fields in request"); 95 | } else{ 96 | 97 | 98 | if( true == $validated ) { 99 | 100 | $bulletin =& JTable::getInstance( 'Bulletin' , 'CTable' ); 101 | $bulletin->title = $data['title']; 102 | $bulletin->message = $data['message']; 103 | $bulletin->id = $data['bulletinid']; 104 | $validated = true; 105 | 106 | 107 | $bulletin->id = $data['bulletinid']; 108 | $bulletin->groupid = $data['groupid']; 109 | $bulletin->date = gmdate( 'Y-m-d H:i:s' ); 110 | $bulletin->created_by = $data['createdby']; 111 | 112 | if($data['published']==""){ 113 | $bulletin->published = 1; 114 | }else{ 115 | $bulletin->published = $data['published']; 116 | } 117 | 118 | $bulletin->store(); 119 | } 120 | 121 | } 122 | 123 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 124 | $res= array(); 125 | foreach( $error_messages as $key => $error_message ) 126 | { 127 | $res[] = $error_message; 128 | 129 | } 130 | 131 | $response = array("id" => 0,'errors'=>$res); 132 | } else { 133 | $response = array('id' => $bulletin->id); 134 | } 135 | 136 | return $response; 137 | 138 | 139 | } 140 | 141 | 142 | } 143 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_announcement_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Update Group Announcement- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an update group announcement plugin 12 | 13 | group_announcement_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_create.php: -------------------------------------------------------------------------------- 1 | createnewgroupdiscussion( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewgroupdiscussion( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | CFactory::load( 'libraries' , 'apps' ); 50 | 51 | $error_messages = array(); 52 | $response = NULL; 53 | $validated = true; 54 | $db = &JFactory::getDBO(); 55 | $survey_filepath = JPATH_ROOT.DS.'configuration'.DS.'surveyfiles'.DS.$data['survey_filename']; 56 | 57 | if( "" == $data['creator'] || 0 == $data['creator']) { 58 | $validated = false; 59 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"Creator cannot be blank"); 60 | } 61 | 62 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 63 | $validated = false; 64 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 65 | } 66 | if( $data['title'] == "" || 0 == strlen($data['title'])) 67 | { 68 | $validated = false; 69 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"Title cannot be blank"); 70 | } 71 | 72 | if($data['message'] == "" || 0 == strlen($data['message'])) 73 | { 74 | $validated = false; 75 | $error_messages[] = array("id"=>1,"fieldname"=>"message","message"=>"Message cannot be blank"); 76 | } 77 | 78 | 79 | $inputFilter = CFactory::getInputFilter( true ); 80 | $validated = true; 81 | 82 | 83 | 84 | if( true == $validated ) { 85 | 86 | // Bind the data with the table first 87 | $discussion =& JTable::getInstance( 'Discussion' , 'CTable' ); 88 | $discussion->set( 'title', strip_tags( $data['title'] )); 89 | $discussion->set( 'message', $inputFilter->clean( $data['message'] )); 90 | $discussion->set( 'groupid', $data['groupid'] ); 91 | $discussion->set( 'creator', $data['creator'] ); 92 | $discussion->set( 'created', gmdate( 'Y-m-d H:i:s' )); 93 | $discussion->set( 'lastreplied',$discussion->created ); 94 | 95 | 96 | $isNew = is_null( $discussion->id ) || !$discussion->id ? true : false; 97 | 98 | $query = "SELECT id FROM #__users WHERE id =".$data['creator']; 99 | $db->setQuery($query); 100 | $creator = $db->LoadResult(); 101 | 102 | $query = "SELECT id FROM #__community_groups WHERE id =".$data['groupid']; 103 | $db->setQuery($query); 104 | $isgroup = $db->LoadResult(); 105 | 106 | if(!$creator){ 107 | 108 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"Invalid discussion creator id. Check 'creator' field in request"); 109 | } 110 | if(!$isgroup){ 111 | 112 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'groupid' field in request"); 113 | }else{ 114 | 115 | if(!file_exists($survey_filepath)) 116 | { 117 | $validated = false; 118 | $error_messages[] = array("id"=>1,"fieldname"=>"survey_filename","message"=>"Invalid Survey File Name"); 119 | 120 | } else { 121 | // Save the discussion. 122 | $discussion->store(); 123 | 124 | $survey = new stdClass; 125 | $survey->group_id = $data['groupid']; 126 | $survey->discussion_id = $discussion->id; 127 | $survey->status = 0; 128 | $survey->timestamp = date('Y-m-d H:i:s'); 129 | $survey->filename = $data['survey_filename']; 130 | $db->insertObject( '#__myhsclosure_survey', $survey,'discussion_id'); 131 | 132 | } 133 | 134 | } 135 | 136 | 137 | //add user points 138 | CFactory::load( 'libraries', 'userpoints' ); 139 | CUserPoints::assignPoint( 'group.discussion.create' ); 140 | if(!$creator) 141 | { 142 | 143 | }if(!$isgroup) 144 | { 145 | 146 | }else if($data['isqm']!='') 147 | { 148 | $db = &JFactory::getDBO(); 149 | $row = new stdClass; 150 | $row->id = NULL; 151 | $row->discussion_id = $discussion->id; 152 | $row->qm_flag = $data['isqm']; 153 | $db->insertObject( '#__myhs_qmflag', $row, 'id' ); 154 | } 155 | } 156 | 157 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 158 | $res= array(); 159 | foreach( $error_messages as $key => $error_message ) 160 | { 161 | $res[] = $error_message; 162 | 163 | } 164 | 165 | $response = array("id" => 0,'errors'=>$res); 166 | } else { 167 | $response = array('id' => $discussion->id); 168 | } 169 | 170 | return $response; 171 | 172 | } 173 | 174 | 175 | } 176 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group Discussion- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group discussion plugin 12 | 13 | group_discussion_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_delete.php: -------------------------------------------------------------------------------- 1 | deletegroupdiscussion( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function deletegroupdiscussion( $data ) { 47 | 48 | 49 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 50 | CFactory::load( 'libraries' , 'apps' ); 51 | 52 | $error_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | 56 | 57 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 58 | $validated = false; 59 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 60 | } 61 | 62 | 63 | $inputFilter = CFactory::getInputFilter( true ); 64 | $validated = true; 65 | 66 | if( true == $validated ) { 67 | if($data['discuss_id']=="" || $data['discuss_id']=="0"){ 68 | $error_messages[] = array("id"=>1,"fieldname"=>"discussid","message"=>"Discuss id cannot be blank"); 69 | }else{ 70 | 71 | CFactory::load( 'helpers' , 'owner' ); 72 | CFactory::load( 'models' , 'discussions' ); 73 | $groupsModel =& CFactory::getModel( 'groups' ); 74 | $wallModel =& CFactory::getModel( 'wall' ); 75 | $discussion =& JTable::getInstance( 'Discussion' , 'CTable' ); 76 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 77 | $group->load( $groupid ); 78 | //$isGroupAdmin = $groupsModel->isAdmin( $my->id , $group->id ); 79 | $discussion->set( 'id', strip_tags( $data['discuss_id'] )); 80 | 81 | if( $discussion->delete() ) 82 | { 83 | // Remove the replies to this discussion as well since we no longer need them 84 | $wallModel->deleteAllChildPosts( $data['discuss_id'] , 'discussions' ); 85 | 86 | // Substract the count from the groups table 87 | $groupsModel->substractDiscussCount( $groupid ); 88 | 89 | //$success_message = "Group discussion id[" . $discussion->id . "] deleted successfully."; 90 | 91 | } 92 | } 93 | } 94 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 95 | $res= array(); 96 | foreach( $error_messages as $key => $error_message ) 97 | { 98 | $res[] = $error_message; 99 | 100 | } 101 | 102 | $response = array("id" => 0,'errors'=>$res); 103 | } else { 104 | $response = array('id' => $discussion->id); 105 | } 106 | 107 | return $response; 108 | 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Group Discussion- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete group discussion plugin 12 | 13 | group_discussion_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_list.php: -------------------------------------------------------------------------------- 1 | Quote($group_id); 67 | $flag = false; 68 | } 69 | 70 | if ($user_id) { 71 | $where[] = 'd.creator = ' . $db->Quote($user_id); 72 | $flag = false; 73 | } 74 | 75 | if ($username) { 76 | $where[] = "u.username LIKE '%".$username."%'"; 77 | $flag = false; 78 | } 79 | 80 | if($startdt && $enddt){ 81 | $where[] = ' date(d.lastreplied) >= "'.$startdt. '" AND date(d.lastreplied) <= "'.$enddt.'"'; 82 | $flag = false; 83 | } 84 | 85 | $where[]= " d.creator = u.id"; 86 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 87 | 88 | if(!$flag) 89 | { 90 | $qry = "SELECT d.id AS discussionid,d.groupid AS groupid,d.creator AS userid,d.title,d.message,d.lastreplied 91 | FROM #__community_groups_discuss As d, #__users AS u 92 | {$where} LIMIT {$start}, {$limit}"; 93 | $db->setQuery($qry); 94 | $discussrec = $db->loadAssocList(); 95 | $discusscount = count($discussrec); 96 | 97 | if($discusscount) { 98 | $discuss = array('size' => $discusscount,'records'=>$discussrec); 99 | }else{ 100 | $discuss = array('size' => 0); 101 | } 102 | 103 | }else{ 104 | $discuss=false; 105 | } 106 | 107 | if(!$discuss){ 108 | $discusserror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Discuss id is not available'); 109 | $discusserror[] = array("id"=>1,"fieldname"=>"groupid",'message'=>'Group id is not available'); 110 | $discusserror[] = array("id"=>1,"fieldname"=>"userid",'message'=>'Userid is not available'); 111 | $discusserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 112 | $discusserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 113 | $discusserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 114 | 115 | $discuss = array('size' => -1,'errors'=>$discusserror); 116 | } 117 | 118 | return $discuss; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group Discussion List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group discussion list plugin 12 | 13 | group_discussion_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_create.php: -------------------------------------------------------------------------------- 1 | createnewdiscussionreplies( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewdiscussionreplies( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | 50 | $error_messages = array(); 51 | $response = NULL; 52 | $validated = true; 53 | $db = &JFactory::getDBO(); 54 | 55 | 56 | if( "" == $data['postby'] || 0 == strlen( $data['postby'] )) { 57 | $validated = false; 58 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"postby cannot be blank"); 59 | } 60 | 61 | if("0" == $data['discussionid'] || "" == $data['discussionid']){ 62 | $validated = false; 63 | $error_messages[] = array("id"=>1,"fieldname"=>"discussionid","message"=>"discussionid (groupdiscussionid) cannot be blank"); 64 | } 65 | 66 | 67 | if( $data['content'] =="") { 68 | $validated = false; 69 | $error_messages[] = array("id"=>1,"fieldname"=>"content","message"=>"Content cannot be blank"); 70 | } 71 | 72 | if( true == $validated ) { 73 | 74 | $user =& JFactory::getUser(); 75 | $user->load( $data['postby']); 76 | 77 | CFactory::load( 'libraries', 'activities' ); 78 | CFactory::load( 'libraries', 'wall' ); 79 | CFactory::load( 'helpers', 'url' ); 80 | CFactory::load( 'helpers', 'owner' ); 81 | CFactory::load( 'helpers', 'time' ); 82 | CFactory::load( 'models', 'discussions' ); 83 | 84 | $discussionModel= CFactory::getModel( 'Discussions' ); 85 | $discussion =& JTable::getInstance( 'Discussion', 'CTable' ); 86 | 87 | $now =& JFactory::getDate(); 88 | $now = $now->toMySQL(); 89 | 90 | // Set the wall properties 91 | $wall =& JTable::getInstance( 'Wall' , 'CTable' ); 92 | $wall->comment = strip_tags( $data['content'] ); 93 | $wall->type = 'discussions'; 94 | $wall->contentid= $data['discussionid']; 95 | $wall->post_by = $data['postby']; 96 | $wall->date = $now; 97 | $wall->published= 1; // need to add kind of setting for this. 98 | $wall->ip = $_SERVER['REMOTE_ADDR']; 99 | 100 | $query = "SELECT id FROM #__community_groups_discuss WHERE id =".$data['discussionid']; 101 | $db->setQuery($query); 102 | $isdiscussion = $db->LoadResult(); 103 | if($data['discussionid']!="") 104 | { 105 | if(!$isdiscussion) 106 | { 107 | $error_messages[] = array("id"=>1,"fieldname"=>"discussionid","message"=>"Invalid discussion id (groupdiscussionid). Check 'discussionid' field in request"); 108 | } 109 | else 110 | { 111 | 112 | 113 | // Save the wall content 114 | $query = "SELECT id FROM #__users WHERE id =".$data['postby']; 115 | $db->setQuery($query); 116 | $postby = $db->LoadResult(); 117 | if(!$postby){ 118 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"Invalid postby(userid). Check 'postby' field in request"); 119 | }else{ 120 | $wall->store(); 121 | 122 | } 123 | } 124 | } 125 | 126 | 127 | } 128 | 129 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 130 | { 131 | 132 | $res= array(); 133 | foreach( $error_messages as $key => $error_message ) 134 | { 135 | $res[] = $error_message; 136 | 137 | } 138 | 139 | $response = array("id" => 0,'errors'=>$res); 140 | } else { 141 | $response = array('id' => $wall->id); 142 | } 143 | 144 | return $response; 145 | 146 | } 147 | 148 | 149 | } 150 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group Discussion Replies- Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group discussion replies plugin 12 | 13 | group_discussion_replies_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_delete.php: -------------------------------------------------------------------------------- 1 | deleterepliespost( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | /* 46 | 47 | */ 48 | function deleterepliespost( $data ) { 49 | 50 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 51 | 52 | $error_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | $db = &JFactory::getDBO(); 56 | 57 | if($data['wall_id']=="" || $data['wall_id']=="0") { 58 | $validated = false; 59 | $error_messages[] = array("id"=>1,"fieldname"=>"wall_id","message"=>"Wall id cannot be blank"); 60 | } 61 | 62 | //@rule: Check if user is really allowed to remove the current wall 63 | $my = CFactory::getUser(); 64 | $model =& CFactory::getModel( 'wall' ); 65 | $wall = $model->get( $data['wall_id'] ); 66 | 67 | $groupModel =& CFactory::getModel( 'groups' ); 68 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 69 | $group->load( $wall->contentid ); 70 | 71 | CFactory::load( 'helpers' , 'owner' ); 72 | $query = "SELECT id FROM #__community_wall WHERE id ='".$data['wall_id']."' AND type = 'discussions'"; 73 | $db->setQuery($query); 74 | $isdiscussion = $db->LoadResult(); 75 | if(!$isdiscussion){ 76 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"wall id for type discussion does not exists. Modify the wall_id field"); 77 | }else{ 78 | if( !$model->deletePost( $data['wall_id'] ) ) 79 | { 80 | $validated = false; 81 | //$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request'; 82 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"wall id does not exists. Modify the wall_id field"); 83 | } 84 | else 85 | { 86 | if($wall->post_by != 0) 87 | { 88 | //add user points 89 | CFactory::load( 'libraries' , 'userpoints' ); 90 | CUserPoints::assignPoint('wall.remove', $wall->post_by); 91 | } 92 | } 93 | 94 | // Substract the count 95 | $groupModel->substractWallCount( $wall->contentid ); 96 | } 97 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 98 | $res= array(); 99 | foreach( $error_messages as $key => $error_message ) 100 | { 101 | $res[] = $error_message; 102 | 103 | } 104 | 105 | $response = array("id" => 0,'errors'=>$res); 106 | } else { 107 | $response = array('id' => $wall->id); 108 | } 109 | 110 | return $response; 111 | 112 | } 113 | 114 | } 115 | 116 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Group discussion replies - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete group discussion replies plugin 12 | 13 | group_discussion_replies_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_list.php: -------------------------------------------------------------------------------- 1 | = "'.$startdt. '" AND date(w.date) <= "'.$enddt.'"'; 81 | $flag = false; 82 | } 83 | 84 | $where[]= " w.contentid = d.id AND w.post_by = u.id AND w.published = 1 AND w.type = 'discussions' "; 85 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 86 | 87 | if(!$flag) 88 | { 89 | $qry = "SELECT w.id AS wallpostid,w.contentid AS groupdiscussionid,w.post_by AS userid,w.date,w.comment 90 | FROM #__community_wall AS w, #__community_groups_discuss AS d, #__users AS u 91 | {$where} LIMIT {$start}, {$limit}"; 92 | $db->setQuery($qry); 93 | $dissreprec = $db->loadAssocList(); 94 | $dissrepcount = count($dissreprec); 95 | 96 | if($dissrepcount) { 97 | $dissrep = array('size' => $dissrepcount,'records'=>$dissreprec); 98 | } else { 99 | $dissrep = array('size' => 0); 100 | } 101 | 102 | } else { 103 | $dissrep = false; 104 | } 105 | 106 | if(!$dissrep) { 107 | $dissreperror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Group Discussions reply post id is not available'); 108 | $dissreperror[] = array("id"=>1,"fieldname"=>"groupid",'message'=>'Groupid is not available'); 109 | $dissreperror[] = array("id"=>1,"fieldname"=>"groupdiscussionid",'message'=>'Group Discussion id is not available'); 110 | $dissreperror[] = array("id"=>1,"fieldname"=>"userid",'message'=>'Userid is not available'); 111 | $dissreperror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 112 | $dissreperror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 113 | $dissreperror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 114 | 115 | $dissrep = array('size' => -1,'errors'=>$dissreperror); 116 | } 117 | 118 | return $dissrep; 119 | } 120 | 121 | 122 | } // end class 123 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group Discussion Replies List 4 | Deepak Patil 5 | 6 Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | deepak.p@tekdi.net 9 | www.tekdi.net 10 | 1.5 11 | An example of an Group Replies list plugin 12 | 13 | group_discussion_replies_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_update.php: -------------------------------------------------------------------------------- 1 | updatediscussionreplies( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function updatediscussionreplies( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | 50 | $error_messages = array(); 51 | $response = NULL; 52 | $validated = true; 53 | $db = &JFactory::getDBO(); 54 | 55 | if( "" == $data['postby'] || 0 == strlen( $data['postby'] )) { 56 | $validated = false; 57 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"postby cannot be blank"); 58 | } 59 | 60 | if( "0" == $data['discussion_id'] && "" == $data['discussion_id']) { 61 | $validated = false; 62 | $error_messages[] = array("id"=>1,"fieldname"=>"discussionid","message"=>"discussion_id cannot be blank"); 63 | } 64 | if( $data['content'] =="") { 65 | $validated = false; 66 | $error_messages[] = array("id"=>1,"fieldname"=>"content","message"=>"Content cannot be blank"); 67 | } 68 | if( $data['wall_id']=="") { 69 | $validated = false; 70 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"Wall id cannot be blank"); 71 | } 72 | 73 | if( true == $validated ) 74 | { 75 | 76 | $user =& JFactory::getUser(); 77 | $user->load( $data['postby']); 78 | 79 | CFactory::load( 'libraries', 'activities' ); 80 | CFactory::load( 'libraries', 'wall' ); 81 | CFactory::load( 'helpers', 'url' ); 82 | CFactory::load( 'helpers', 'owner' ); 83 | CFactory::load( 'helpers', 'time' ); 84 | CFactory::load( 'models', 'groups' ); 85 | CFactory::load( 'models', 'discussions' ); 86 | 87 | $discussionModel= CFactory::getModel( 'Discussions' ); 88 | $discussion =& JTable::getInstance( 'Discussion', 'CTable' ); 89 | 90 | $group =& JTable::getInstance( 'Group', 'CTable' ); 91 | 92 | $now =& JFactory::getDate(); 93 | $now = $now->toMySQL(); 94 | 95 | // Set the wall properties 96 | $wall =& JTable::getInstance( 'Wall' , 'CTable' ); 97 | $wall->comment = strip_tags( $data['content'] ); 98 | $wall->id = $data['wall_id']; 99 | $wall->type = $appType; 100 | $wall->type = 'discussions'; 101 | $wall->contentid = $data['discussion_id']; 102 | $wall->post_by = $data['postby']; 103 | $wall->date = $now; 104 | $wall->published = 1; // need to add kind of setting for this. 105 | $wall->ip = $_SERVER['REMOTE_ADDR']; 106 | 107 | $query = "SELECT id FROM #__community_groups_discuss WHERE id =".$data['discussion_id']; 108 | $db->setQuery($query); 109 | $isdiscussion = $db->LoadResult(); 110 | if($data['discussion_id']!="") 111 | { 112 | if(!$isdiscussion) 113 | { 114 | 115 | $error_messages[] = array("id"=>1,"fieldname"=>"discussionid","message"=>"Invalid discussion id. Check 'discussion_id' field in request"); 116 | } 117 | else 118 | { 119 | 120 | // Save the wall content 121 | $query = "SELECT id FROM #__users WHERE id =".$data['postby']; 122 | $db->setQuery($query); 123 | $postby = $db->LoadResult(); 124 | if(!$postby){ 125 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"Invalid postby id(userid). Check 'postby' field in request"); 126 | }else{ 127 | $wall->store(); 128 | 129 | } 130 | } 131 | } 132 | 133 | } 134 | 135 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 136 | $res= array(); 137 | foreach( $error_messages as $key => $error_message ) 138 | { 139 | $res[] = $error_message; 140 | 141 | } 142 | 143 | $response = array("id" => 0,'errors'=>$res); 144 | } else { 145 | $response = array('id' => $wall->id); 146 | } 147 | 148 | return $response; 149 | 150 | } 151 | 152 | 153 | } 154 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_replies_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Update Discussion Replies - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an update discussion replies plugin 12 | 13 | group_discussion_replies_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_discussion_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Update Group Discussion- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an update group discussion plugin 12 | 13 | group_discussion_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_list.php: -------------------------------------------------------------------------------- 1 | = "'.$startdt. '" AND date(g.created) <= "'.$enddt.'"'; 76 | $flag = false; 77 | } 78 | 79 | $where[]= " g.ownerid = u.id AND g.published = 1 "; 80 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 81 | 82 | if(!$flag) 83 | { 84 | $qry = "SELECT g.id AS groupid,g.name AS groupname,g.description,g.email,g.website,g.created 85 | FROM #__community_groups As g, #__users AS u 86 | {$where} LIMIT {$start}, {$limit}"; 87 | $db->setQuery($qry); 88 | $grouprec = $db->loadAssocList(); 89 | $groupcount = count($grouprec); 90 | 91 | if($groupcount) { 92 | $grouplist = array('size' => $groupcount,'records'=>$grouprec); 93 | }else{ 94 | $grouplist = array('size' => 0); 95 | } 96 | 97 | }else{ 98 | $grouplist=false; 99 | } 100 | 101 | if(!$grouplist){ 102 | $grouplisterror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Group id is not available'); 103 | $grouplisterror[] = array("id"=>1,"fieldname"=>"groupname",'message'=>'Group Name is not available'); 104 | $grouplisterror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 105 | $grouplisterror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 106 | $grouplisterror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 107 | 108 | $grouplist = array('size' => -1,'errors'=>$grouplisterror); 109 | } 110 | 111 | return $grouplist; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group list plugin 12 | 13 | group_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_member_list.php: -------------------------------------------------------------------------------- 1 | groupmemberlist( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function groupmemberlist( $data ) 47 | { 48 | 49 | $error_messages = array(); 50 | $response = NULL; 51 | $validated = true; 52 | 53 | 54 | if($data['groupid']=='' || $data['groupid']=='0') 55 | { 56 | $validated = false; 57 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 58 | } 59 | 60 | if( true == $validated ) 61 | { 62 | 63 | $db = &JFactory::getDBO(); 64 | $query = "SELECT id FROM #__community_groups WHERE id = '".$data['groupid']."'"; 65 | $db->setQuery($query); 66 | $group_id = $db->loadResult(); 67 | if(!$group_id){ 68 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'groupid' field in request"); 69 | }else{ 70 | 71 | $query = "SELECT m.memberid, u.id, u.name, u.username, u.email, u.registerDate as registerdate, u.usertype 72 | FROM #__community_groups_members As m, #__users AS u 73 | WHERE m.memberid = u.id AND m.groupid = '".$data['groupid']."'"; 74 | $db->setQuery($query); 75 | $result = $db->loadAssocList(); 76 | 77 | 78 | /*for($i=0;$isetQuery($query); 84 | $memberdata = $db->loadObjectList(); 85 | 86 | foreach($memberdata as $memberinfo) 87 | { 88 | 89 | $result[$i]['id'] = $memberinfo->id; 90 | $result[$i]['name'] = $memberinfo->name; 91 | $result[$i]['username'] = $memberinfo->username; 92 | $result[$i]['email'] = $memberinfo->email; 93 | $result[$i]['registerDate'] = $memberinfo->registerDate; 94 | $result[$i]['usertype'] = $memberinfo->usertype; 95 | 96 | } 97 | 98 | }*/ 99 | } 100 | } 101 | 102 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 103 | { 104 | $res= array(); 105 | foreach( $error_messages as $key => $error_message ) 106 | { 107 | $res[] = $error_message; 108 | 109 | } 110 | 111 | $response = array("size" => -1,'errors'=>$res); 112 | //$response = $res; 113 | } else { 114 | if(count($result)){ 115 | 116 | $response = array('size' => count($result),'records'=>$result); 117 | }else{ 118 | $response = array('size' => 0); 119 | } 120 | //$response = $result; 121 | 122 | } 123 | 124 | return $response; 125 | 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_member_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group Member List - Example 4 | Joomla! Project 5 | Dec 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group member list plugin 12 | 13 | group_member_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_members_create.php: -------------------------------------------------------------------------------- 1 | createnewgroupmembers( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewgroupmembers( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | CFactory::load( 'libraries' , 'apps' ); 50 | 51 | $error_messages = array(); 52 | $success_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | $db = &JFactory::getDBO(); 56 | 57 | 58 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 59 | $validated = false; 60 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 61 | } 62 | 63 | if( false == array_key_exists( 'memberids', $data ) || 0 == sizeof( $data['memberids'] ) || $data['memberids'] == "") { 64 | $validated = false; 65 | $error_messages[] = array("id"=>1,"fieldname"=>"memberids","message"=>"Memberids cannot be blank"); 66 | } 67 | 68 | if( true == $validated ) { 69 | $membersid = array(); 70 | if(!is_array($data['memberids'])) 71 | $data['memberids'] = array($data['memberids']); 72 | 73 | foreach( $data['memberids'] as $memberid ) { 74 | $query = "SELECT id FROM #__users WHERE id =".$memberid; 75 | $db->setQuery($query); 76 | $ismemberid = $db->LoadResult(); 77 | if(!$ismemberid){ 78 | 79 | }else{ 80 | // create instance of group member 81 | $member =& JTable::getInstance( 'GroupMembers' , 'CTable' ); 82 | $member->set( 'groupid', $data['groupid'] ); 83 | $member->set( 'memberid', $memberid ); 84 | $member->set( 'approved', 1 ); 85 | $member->set( 'permissions', 1 ); 86 | 87 | $query = "SELECT id FROM #__community_groups WHERE id =".$data['groupid']; 88 | $db->setQuery($query); 89 | $isgroup = $db->LoadResult(); 90 | if(!$isgroup){ 91 | //$error_messages[] = "Invalid group id. Check 'groupid' field in request"; 92 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'groupid' field in request"); 93 | }else{ 94 | if(!$member->store()) 95 | { 96 | //$error_messages[] = "Member not inserted. please check 'memberid' field in request"; 97 | $error_messages[] = array("id"=>1,"fieldname"=>"memberids","message"=>"Member not inserted. please check 'memberids' field in request"); 98 | 99 | } 100 | 101 | $membersid[]=$member->memberid; 102 | 103 | } 104 | 105 | } 106 | 107 | } 108 | 109 | 110 | $db =& JFactory::getDBO(); 111 | $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote( '#__community_groups_members' ) . ' ' 112 | . 'WHERE groupid=' . $db->Quote( $data['groupid']) . ' ' 113 | . 'AND approved=' . $db->Quote( '1' ); 114 | 115 | $db->setQuery( $query ); 116 | $membercount = $db->loadResult(); 117 | 118 | $members = new stdClass(); 119 | $members->id = $data['groupid']; 120 | $members->membercount = $membercount; 121 | $db->updateObject( '#__community_groups' , $members , 'id'); 122 | 123 | } 124 | 125 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 126 | $res= array(); 127 | foreach( $error_messages as $key => $error_message ) 128 | { 129 | $res[] = $error_message; 130 | 131 | } 132 | 133 | $response = array("id" => 0,'errors'=>$res); 134 | } else { 135 | $response = array('memberid' => $membersid ); 136 | } 137 | 138 | return $response; 139 | 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_members_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group Members- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group members plugin 12 | 13 | group_members_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_members_delete.php: -------------------------------------------------------------------------------- 1 | deletegroupmembers( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function deletegroupmembers( $data ) 47 | { 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | CFactory::load( 'libraries' , 'apps' ); 50 | 51 | $error_messages = array(); 52 | $success_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | 56 | 57 | 58 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 59 | $validated = false; 60 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 61 | } 62 | 63 | if( false == array_key_exists( 'memberids', $data ) || 0 == sizeof( $data['memberids'] )) { 64 | $validated = false; 65 | $error_messages[] = array("id"=>1,"fieldname"=>"memberids","message"=>"Memberids cannot be blank"); 66 | } 67 | 68 | if( true == $validated ) { 69 | 70 | $model =& CFactory::getModel( 'groups' ); 71 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 72 | $group->id = $data['groupid']; 73 | $group->ownerid = $data['ownerid']; 74 | } 75 | 76 | 77 | if($data['ownerid'] == $data['memberids']) 78 | { 79 | $validated = false; 80 | 81 | $error_messages[] = array("id"=>1,"fieldname"=>"ownerid/memberid","message"=>"owner id and member id are same.please update 'ownwrid or memberid' fields in request"); 82 | } 83 | else 84 | { 85 | $groupMember =& JTable::getInstance( 'GroupMembers' , 'CTable' ); 86 | $memberId=$data['memberids']; 87 | $groupId=$data['groupid']; 88 | $groupMember->load( $memberId , $groupId ); 89 | 90 | $data = new stdClass(); 91 | 92 | $data->groupid = $groupId; 93 | $data->memberid = $memberId; 94 | 95 | 96 | 97 | $data = new stdClass(); 98 | 99 | $data->groupid = $groupId; 100 | $data->memberid = $memberId; 101 | 102 | $model->removeMember($data); 103 | 104 | 105 | $db =& JFactory::getDBO(); 106 | $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote( '#__community_groups_members' ) . ' ' 107 | . 'WHERE groupid=' . $db->Quote( $groupId) . ' ' 108 | . 'AND approved=' . $db->Quote( '1' ); 109 | 110 | $db->setQuery( $query ); 111 | $membercount = $db->loadResult(); 112 | 113 | $members = new stdClass(); 114 | $members->id = $groupId; 115 | $members->membercount = $membercount; 116 | $db->updateObject( '#__community_groups' , $members , 'id'); 117 | 118 | //add user points 119 | CFactory::load( 'libraries' , 'userpoints' ); 120 | CUserPoints::assignPoint('group.member.remove', $memberId); 121 | 122 | 123 | } 124 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 125 | $res= array(); 126 | foreach( $error_messages as $key => $error_message ) 127 | { 128 | $res[] = $error_message; 129 | 130 | } 131 | 132 | $response = array("id" => 0,'errors'=>$res); 133 | } else { 134 | $response = array('id' => $memberId); 135 | } 136 | 137 | return $response; 138 | 139 | } 140 | 141 | 142 | } 143 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/group_members_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Group Members- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete group members plugin 12 | 13 | group_members_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/search.php: -------------------------------------------------------------------------------- 1 | doSearch(); 30 | 31 | // Process them like Joomla does 32 | for ($i=0; $i < count($results); $i++) 33 | { 34 | $row = &$results[$i]->text; 35 | 36 | if ($match == 'exact') 37 | { 38 | $searchwords = array($searchword); 39 | $needle = $searchword; 40 | } 41 | else 42 | { 43 | $searchwords = preg_split("/\s+/u", $searchword); 44 | $needle = $searchwords[0]; 45 | } 46 | 47 | $row = SearchHelper::prepareSearchContent( $row, 200, $needle ); 48 | $searchwords = array_unique( $searchwords ); 49 | /* $searchRegex = '#('; 50 | $x = 0; 51 | foreach ($searchwords as $k => $hlword) 52 | { 53 | $searchRegex .= ($x == 0 ? '' : '|'); 54 | $searchRegex .= preg_quote($hlword, '#'); 55 | $x++; 56 | } 57 | $searchRegex .= ')#iu'; 58 | */ 59 | $result =& $results[$i]; 60 | if ($result->created) { 61 | $created = $result->created; 62 | } 63 | else { 64 | $created = ''; 65 | } 66 | 67 | $result->created = $created; 68 | $result->count = $i + 1; 69 | } 70 | return $results; 71 | } 72 | 73 | 74 | function doSearch() 75 | { 76 | $searchmodel = new SearchModelSearch();//JFactory::getModel('search'); 77 | $results = $searchmodel->getData(); 78 | 79 | return $results; 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/search.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | REST - Search 4 | Ashwin Date 5 | 06/05/2011 6 | Copyright (C) 2011 Tekdi Web Solutions. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | extensions@techjoomla.com 9 | www.techjoomla.com 10 | 1.5 11 | Search API 12 | 13 | search.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Authentication - Example 4 | Joomla! Project 5 | November 2005 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an authentication plugin 12 | 13 | user_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_delete.php: -------------------------------------------------------------------------------- 1 | deleteuser( $data ); 38 | return $id; 39 | } 40 | 41 | function onRestInfo() { 42 | 43 | } 44 | 45 | 46 | 47 | function deleteuser( $data ) { 48 | 49 | jimport('joomla.user.helper'); 50 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 51 | require_once( JPATH_SITE .'/libraries/joomla/filesystem/folder.php'); 52 | $authorize = & JFactory::getACL(); 53 | //$user = JFactory::getUser(); 54 | $user =& JUser::getInstance((int)$data['userid']); 55 | $error_messages = array(); 56 | $response = NULL; 57 | $validated = true; 58 | 59 | 60 | $validated = true; 61 | 62 | //$user->set('id', $data['userid']); 63 | 64 | if(!$user->id || $data['userid']=="" || $data['userid']=="0") { 65 | $validated = false; 66 | 67 | $error_messages[] = array("id"=>1,"fieldname"=>"userid","message"=>"Userid cannot be blank"); 68 | } 69 | if( true == $validated ) { 70 | if(!$user->delete()) 71 | { 72 | 73 | $error_messages[] = array("id"=>1,"fieldname"=>"userid","message"=>"userid not exist modify the field userid"); 74 | } 75 | } 76 | 77 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 78 | { 79 | $res= array(); 80 | foreach( $error_messages as $key => $error_message ) 81 | { 82 | $res[] = $error_message; 83 | 84 | } 85 | 86 | $response = array("id" => 0,'errors'=>$res); 87 | } else { 88 | $response = array('id' => $user->id); 89 | } 90 | 91 | return $response; 92 | } 93 | 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete User - Example 4 | Joomla! Project 5 | November 2005 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an Delete user plugin 12 | 13 | user_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_list.php: -------------------------------------------------------------------------------- 1 | $v) { 20 | $usersdata[$k]['jspt'] = XiptAPI::getUserProfiletype($v['id']); 21 | $usersdata[$k]['jsptname'] = XiptAPI::getUserProfiletype($v['id'], 'name'); 22 | } 23 | 24 | return $usersdata; 25 | } 26 | 27 | function onRestCall ($data) { 28 | 29 | $db = JFactory::getDBO(); 30 | $start = JRequest::getInt('start', 0); 31 | $limit = JRequest::getInt('limit', 20); 32 | $id = JRequest::getInt('id'); 33 | $email = JRequest::getVar('email'); 34 | $name = JRequest::getVar('name'); 35 | $username = JRequest::getVar('username'); 36 | $startdt = JRequest::getVar('startdate'); 37 | $enddt = JRequest::getVar('enddate'); 38 | $modifieddt = JRequest::getVar('modifieddate'); 39 | $where = array(); 40 | $wheresql = ''; 41 | $flag = false; 42 | 43 | if ($id!="" && $id!=0 && $id) { 44 | $where[] = 'id = ' . $id; 45 | $flag = false; 46 | } 47 | 48 | if ($email) { 49 | $where[] = 'email = ' . $db->Quote($email); 50 | $flag = false; 51 | } 52 | 53 | if ($name) { 54 | $where[] = "name LIKE '%".$name."%'"; 55 | $flag = false; 56 | } 57 | 58 | if ($username) { 59 | $where[] = "username LIKE '%" . $username . "%'"; 60 | $flag = false; 61 | } 62 | 63 | if($startdt && $enddt){ 64 | $where[] = ' date(registerDate) >= "'.$startdt. '" AND date(registerDate) <= "'.$enddt.'"'; 65 | $flag = false; 66 | } 67 | 68 | if($modifieddt){ 69 | $where[] = "date(lastvisitDate) LIKE '%".$modifieddt. "%'"; 70 | $flag = false; 71 | } 72 | 73 | if (count($where)) { 74 | $wheresql = 'WHERE block = 0 AND ' . implode(' AND ', $where); 75 | } 76 | 77 | if(!$flag){ 78 | $qry = "SELECT id, name, username, email, registerDate as registerdate, usertype 79 | FROM #__users {$wheresql} LIMIT {$start}, {$limit}"; 80 | 81 | $db->setQuery($qry); 82 | $usersrec = $db->loadAssocList(); 83 | $userscount = count($usersrec); 84 | 85 | if($userscount){ 86 | $usersrec = $this->_extendUsers($usersrec); 87 | $users = array('size' => $userscount,'records'=>$usersrec); 88 | }else{ 89 | $users = array('size' => 0); 90 | } 91 | 92 | }else{ 93 | $users=false; 94 | } 95 | 96 | if(!$users){ 97 | $userserror[] = array("id"=>1,"fieldname"=>"name",'message'=>'name is not available'); 98 | $userserror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Discuss id is not available'); 99 | $userserror[] = array("id"=>1,"fieldname"=>"email",'message'=>'Email id is not available'); 100 | $userserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 101 | $userserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 102 | $userserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 103 | $userserror[] = array("id"=>1,"fieldname"=>"modifieddate",'message'=>'Modified date is not valid'); 104 | $users = array('size' => -1,'errors'=>$userserror); 105 | } 106 | 107 | return $users; 108 | } 109 | 110 | 111 | } 112 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User List 4 | Ashwin Date 5 | 30/09/2010 6 | Copyright (C) 2010 Tekdi Web Solutions 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | ashwin.date@tekdi.net 9 | www.tekdi.net 10 | 1.5 11 | Returns a list of users 12 | 13 | user_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/user_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Update - Example 4 | Joomla! Project 5 | November 2005 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an user update plugin 12 | 13 | user_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_create.php: -------------------------------------------------------------------------------- 1 | createnewwallpost( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewwallpost( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | 50 | $error_messages = array(); 51 | $response = NULL; 52 | $validated = true; 53 | $db = &JFactory::getDBO(); 54 | 55 | 56 | if( "" == $data['postby'] || 0 == strlen( $data['postby'] )) { 57 | $validated = false; 58 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"postby cannot be blank"); 59 | } 60 | 61 | 62 | if("0" == $data['group_id'] || "" == $data['group_id']){ 63 | $validated = false; 64 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"group_id cannot be blank"); 65 | } 66 | if( $data['content'] =="") { 67 | $validated = false; 68 | $error_messages[] = array("id"=>1,"fieldname"=>"content","message"=>"Content cannot be blank"); 69 | } 70 | 71 | if( true == $validated ) { 72 | 73 | $user =& JFactory::getUser(); 74 | $user->load( $data['postby']); 75 | 76 | CFactory::load( 'libraries', 'activities' ); 77 | CFactory::load( 'libraries', 'wall' ); 78 | CFactory::load( 'helpers', 'url' ); 79 | CFactory::load( 'helpers', 'owner' ); 80 | CFactory::load( 'helpers', 'time' ); 81 | CFactory::load( 'models', 'groups' ); 82 | 83 | $groupModel =& CFactory::getModel( 'groups' ); 84 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 85 | 86 | 87 | $now =& JFactory::getDate(); 88 | $now = $now->toMySQL(); 89 | 90 | // Set the wall properties 91 | $wall =& JTable::getInstance( 'Wall' , 'CTable' ); 92 | $wall->comment = strip_tags( $data['content'] ); 93 | $wall->type = 'groups'; 94 | $wall->contentid= $data['group_id']; 95 | $wall->post_by = $data['postby']; 96 | $wall->date = $now; 97 | $wall->published= 1; // need to add kind of setting for this. 98 | $wall->ip = $_SERVER['REMOTE_ADDR']; 99 | 100 | $group->load( $wall->contentid ); 101 | $query = "SELECT id FROM #__community_groups WHERE id =".$data['group_id']; 102 | $db->setQuery($query); 103 | $isgroup = $db->LoadResult(); 104 | 105 | if($data['group_id']!="") 106 | { 107 | if(!$isgroup) 108 | { 109 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'group_id' field in request"); 110 | }else 111 | { 112 | $query = "SELECT id FROM #__users WHERE id =".$data['postby']; 113 | $db->setQuery($query); 114 | $postby = $db->LoadResult(); 115 | if(!$postby){ 116 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"Invalid postby id(userid). Check 'postby' field in request"); 117 | }else{ 118 | $wall->store(); 119 | 120 | 121 | } 122 | } 123 | 124 | $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote( '#__community_wall' ) . ' ' 125 | . 'WHERE contentid=' . $db->Quote( $data['group_id']) . ' ' 126 | . 'AND type="groups"'; 127 | 128 | $db->setQuery( $query ); 129 | $wall_count = $db->loadResult(); 130 | 131 | $wallcount = new stdClass(); 132 | $wallcount->id = $data['group_id']; 133 | $wallcount->wallcount = $wall_count; 134 | $db->updateObject( '#__community_groups' , $wallcount , 'id'); 135 | //$groupModel->substractWallCount($wall->contentid); 136 | } 137 | } 138 | 139 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) 140 | { 141 | 142 | $res= array(); 143 | foreach( $error_messages as $key => $error_message ) 144 | { 145 | $res[] = $error_message; 146 | 147 | } 148 | 149 | $response = array("id" => 0,'errors'=>$res); 150 | } else { 151 | $response = array('id' => $wall->id); 152 | } 153 | 154 | return $response; 155 | 156 | } 157 | 158 | 159 | } 160 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Wall Post - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create wall post plugin 12 | 13 | wall_post_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_delete.php: -------------------------------------------------------------------------------- 1 | deletewallpost( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | /* 46 | 47 | */ 48 | function deletewallpost( $data ) { 49 | 50 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 51 | 52 | $error_messages = array(); 53 | $response = NULL; 54 | $validated = true; 55 | $db = &JFactory::getDBO(); 56 | 57 | if($data['wall_id']=="" || $data['wall_id']=="0") { 58 | $validated = false; 59 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"Wall id cannot be blank"); 60 | } 61 | 62 | //@rule: Check if user is really allowed to remove the current wall 63 | $my = CFactory::getUser(); 64 | $model =& CFactory::getModel( 'wall' ); 65 | $wall = $model->get( $data['wall_id'] ); 66 | 67 | $groupModel =& CFactory::getModel( 'groups' ); 68 | $group =& JTable::getInstance( 'Group' , 'CTable' ); 69 | $group->load( $wall->contentid ); 70 | $query = "SELECT contentid FROM #__community_wall WHERE id ='".$data['wall_id']."' AND type = 'groups'"; 71 | $db->setQuery($query); 72 | $contentid = $db->LoadResult(); 73 | 74 | CFactory::load( 'helpers' , 'owner' ); 75 | $query = "SELECT id FROM #__community_wall WHERE id ='".$data['wall_id']."' AND type = 'groups'"; 76 | $db->setQuery($query); 77 | $isdiscussion = $db->LoadResult(); 78 | if(!$isdiscussion){ 79 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"wall id for type groups does not exists. Modify the wall_id field"); 80 | }else{ 81 | if( !$model->deletePost( $data['wall_id'] ) ) 82 | { 83 | $validated = false; 84 | //$error_messages[] = 'wall id does not exists. Modify the wall_id fields in request'; 85 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"wall id does not exists. Modify the wall_id field"); 86 | } 87 | else 88 | { 89 | if($wall->post_by != 0) 90 | { 91 | //add user points 92 | CFactory::load( 'libraries' , 'userpoints' ); 93 | CUserPoints::assignPoint('wall.remove', $wall->post_by); 94 | } 95 | 96 | } 97 | //$groupModel->substractWallCount( $data['wall_id'] ); 98 | // Substract the count 99 | $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote( '#__community_wall' ) . ' ' 100 | . 'WHERE contentid=' . $db->Quote($contentid) . ' ' 101 | . 'AND type="groups"'; 102 | 103 | $db->setQuery( $query ); 104 | $wall_count = $db->loadResult(); 105 | 106 | $wallcount = new stdClass(); 107 | $wallcount->id = $contentid; 108 | $wallcount->wallcount = $wall_count; 109 | $db->updateObject( '#__community_groups' , $wallcount , 'id'); 110 | } 111 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 112 | $res= array(); 113 | foreach( $error_messages as $key => $error_message ) 114 | { 115 | $res[] = $error_message; 116 | 117 | } 118 | 119 | $response = array("id" => 0,'errors'=>$res); 120 | } else { 121 | $response = array('id' => $wall->id); 122 | } 123 | 124 | return $response; 125 | 126 | } 127 | 128 | } 129 | 130 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_delete.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Delete Wall Post - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an delete wall post plugin 12 | 13 | wall_post_delete.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_list.php: -------------------------------------------------------------------------------- 1 | = "'.$startdt. '" AND date(w.date) <= "'.$enddt.'"'; 75 | $flag = false; 76 | } 77 | 78 | $where[]= " w.post_by = u.id AND w.published = 1 AND w.type = 'groups' "; 79 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 80 | 81 | if(!$flag) 82 | { 83 | $qry = "SELECT w.id AS wallpostid, w. contentid AS groupid, w.post_by AS userid, w.comment, w.date 84 | FROM #__community_wall As w, #__users AS u 85 | {$where} LIMIT {$start}, {$limit}"; 86 | $db->setQuery($qry); 87 | $wallrec = $db->loadAssocList(); 88 | $wallscount = count($wallrec); 89 | 90 | if($wallscount) { 91 | $walls = array('size' => $wallscount,'records'=>$wallrec); 92 | } else { 93 | $walls = array('size' => 0); 94 | } 95 | 96 | } else { 97 | $walls = false; 98 | } 99 | 100 | if(!$walls) { 101 | $wallserror[] = array("id"=>1,"fieldname"=>"groupid",'message'=>'Groupid is not available'); 102 | $wallserror[] = array("id"=>1,"fieldname"=>"wallpostid",'message'=>'Wall post id is not available'); 103 | $wallserror[] = array("id"=>1,"fieldname"=>"userid",'message'=>'Userid is not available'); 104 | $wallserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 105 | $wallserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 106 | $wallserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 107 | 108 | $walls = array('size' => -1,'errors'=>$wallserror); 109 | } 110 | 111 | return $walls; 112 | } 113 | 114 | 115 | } // end class 116 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wall Post List 4 | Deepak Patil 5 | 6 Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | deepak.p@tekdi.net 9 | www.tekdi.net 10 | 1.5 11 | An example of an wall post list plugin 12 | 13 | wall_post_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_update.php: -------------------------------------------------------------------------------- 1 | updatewallpost( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function updatewallpost( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | 50 | $error_messages = array(); 51 | $response = NULL; 52 | $validated = true; 53 | $db = &JFactory::getDBO(); 54 | 55 | if( "" == $data['postby'] || 0 == strlen( $data['postby'] )) { 56 | $validated = false; 57 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"postby cannot be blank"); 58 | } 59 | 60 | 61 | if( "0" == $data['group_id'] && "" == $data['group_id']) { 62 | $validated = false; 63 | 64 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"group_id cannot be blank"); 65 | } 66 | if( $data['content'] =="") { 67 | $validated = false; 68 | $error_messages[] = array("id"=>1,"fieldname"=>"content","message"=>"Content cannot be blank"); 69 | } 70 | if( $data['wall_id']=="") { 71 | $validated = false; 72 | $error_messages[] = array("id"=>1,"fieldname"=>"wallid","message"=>"Wall id cannot be blank"); 73 | } 74 | 75 | if( true == $validated ) 76 | { 77 | 78 | $user =& JFactory::getUser(); 79 | $user->load( $data['postby']); 80 | 81 | CFactory::load( 'libraries', 'activities' ); 82 | CFactory::load( 'libraries', 'wall' ); 83 | CFactory::load( 'helpers', 'url' ); 84 | CFactory::load( 'helpers', 'owner' ); 85 | CFactory::load( 'helpers', 'time' ); 86 | CFactory::load( 'models', 'groups' ); 87 | CFactory::load( 'models', 'discussions' ); 88 | 89 | $group =& JTable::getInstance( 'Group', 'CTable' ); 90 | 91 | $now =& JFactory::getDate(); 92 | $now = $now->toMySQL(); 93 | 94 | // Set the wall properties 95 | $wall =& JTable::getInstance( 'Wall' , 'CTable' ); 96 | $wall->comment = strip_tags( $data['content'] ); 97 | $wall->id = $data['wall_id']; 98 | $wall->type = $appType; 99 | $wall->type = 'groups'; 100 | $wall->contentid = $data['group_id']; 101 | $wall->post_by = $data['postby']; 102 | $wall->date = $now; 103 | $wall->published = 1; // need to add kind of setting for this. 104 | $wall->ip = $_SERVER['REMOTE_ADDR']; 105 | 106 | $query = "SELECT id FROM #__community_groups WHERE id =".$data['group_id']; 107 | $db->setQuery($query); 108 | $isgroup = $db->LoadResult(); 109 | 110 | if($data['group_id']!="") 111 | { 112 | if(!$isgroup) 113 | { 114 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'group_id' field in request"); 115 | 116 | }else 117 | { 118 | $query = "SELECT id FROM #__users WHERE id =".$data['postby']; 119 | $db->setQuery($query); 120 | $postby = $db->LoadResult(); 121 | if(!$postby){ 122 | $error_messages[] = array("id"=>1,"fieldname"=>"postby","message"=>"Invalid postby id(userid). Check 'postby' field in request"); 123 | }else{ 124 | $wall->store(); 125 | 126 | } 127 | } 128 | } 129 | 130 | } 131 | 132 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 133 | $res= array(); 134 | foreach( $error_messages as $key => $error_message ) 135 | { 136 | $res[] = $error_message; 137 | 138 | } 139 | 140 | $response = array("id" => 0,'errors'=>$res); 141 | } else { 142 | $response = array('id' => $wall->id); 143 | } 144 | 145 | return $response; 146 | 147 | } 148 | 149 | 150 | } 151 | -------------------------------------------------------------------------------- /joomla_1.5/plugins/wall_post_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Update Wall Post - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an update wall post plugin 12 | 13 | wall_post_update.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.5/samples/RESTclient.php: -------------------------------------------------------------------------------- 1 | root_url = $this->curr_url = $root_url; 17 | $this->user_name = $user_name; 18 | $this->password = $password; 19 | if ($root_url != "") { 20 | $this->createRequest("GET"); 21 | $this->sendRequest(); 22 | } 23 | return true; 24 | } 25 | 26 | public function createRequest($url, $method, $arr = null) { 27 | $this->curr_url = $url; 28 | $this->req =& new HTTP_Request($url); 29 | if ($this->user_name != "" && $this->password != "") { 30 | $this->req->setBasicAuth($this->user_name, $this->password); 31 | } 32 | 33 | switch($method) { 34 | case "GET": 35 | $this->req->setMethod(HTTP_REQUEST_METHOD_GET); 36 | break; 37 | case "POST": 38 | $this->req->setMethod(HTTP_REQUEST_METHOD_POST); 39 | $this->addPostData($arr); 40 | break; 41 | case "PUT": 42 | $this->req->setMethod(HTTP_REQUEST_METHOD_PUT); 43 | // to-do 44 | break; 45 | case "DELETE": 46 | $this->req->setMethod(HTTP_REQUEST_METHOD_DELETE); 47 | // to-do 48 | break; 49 | } 50 | } 51 | 52 | private function addPostData($arr) { 53 | 54 | if ($arr != null) { 55 | foreach ($arr as $key => $value) { 56 | $this->req->addPostData($key, $value); 57 | } 58 | } 59 | } 60 | 61 | public function sendRequest() { 62 | $this->response = $this->req->sendRequest(); 63 | 64 | if (PEAR::isError($this->response)) { 65 | echo $this->response->getMessage(); 66 | //die(); 67 | } else { 68 | $this->responseBody = $this->req->getResponseBody(); 69 | } 70 | } 71 | 72 | public function getResponse() { 73 | 74 | return $this->responseBody; 75 | } 76 | 77 | } 78 | ?> 79 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/hand.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; 3 | font-size:12px; 4 | margin:0px; 5 | } 6 | p, h1, form, button{border:0; margin:0; padding:0; 7 | } 8 | .spacer{clear:both; height:1px;} 9 | /* ----------- My Form ----------- */ 10 | .myform{ 11 | margin:0 auto; 12 | padding:14px; 13 | } 14 | /* ----------- basic ----------- */ 15 | #basic{ 16 | border:solid 2px #DEDEDE; 17 | } 18 | #basic h1 { 19 | font-size:14px; 20 | font-weight:bold; 21 | margin-bottom:8px; 22 | } 23 | #basic p{ 24 | font-size:11px; 25 | color:#666666; 26 | margin-bottom:20px; 27 | border-bottom:solid 1px #dedede; 28 | padding-bottom:10px; 29 | } 30 | #basic label{ 31 | display:block; 32 | font-weight:bold; 33 | 34 | width:140px; 35 | 36 | } 37 | #basic .small{ 38 | color:#666666; 39 | display:block; 40 | font-size:11px; 41 | font-weight:normal; 42 | 43 | } 44 | #basic input{ 45 | 46 | width:200px; 47 | margin:2px 0 30px 10px; 48 | } 49 | #basic button{ 50 | clear:both; 51 | margin-left:150px; 52 | background:#888888; 53 | color:#FFFFFF; 54 | border:solid 1px #666666; 55 | font-size:11px; 56 | font-weight:bold; 57 | padding:4px 6px; 58 | } 59 | 60 | 61 | /* ----------- stylized ----------- */ 62 | #stylized{ 63 | border:solid 2px #b7ddf2; 64 | background:#ebf4fb; 65 | } 66 | #stylized h1 { 67 | font-size:14px; 68 | font-weight:bold; 69 | margin-bottom:8px; 70 | } 71 | #stylized p{ 72 | font-size:11px; 73 | color:#666666; 74 | margin-bottom:5px; 75 | border-bottom:solid 1px #b7ddf2; 76 | padding-bottom:10px; 77 | } 78 | #stylized label{ 79 | display:block; 80 | font-weight:bold; 81 | 82 | 83 | } 84 | #stylized .small{ 85 | color:#666666; 86 | display:block; 87 | font-size:11px; 88 | font-weight:normal; 89 | 90 | } 91 | #stylized input, #stylized select, #stylized textarea{ 92 | 93 | font-size:12px; 94 | padding:4px 2px; 95 | border:solid 1px #aacfe4; 96 | width:200px; 97 | margin:2px 0 10px 0px; 98 | } 99 | #stylized button{ 100 | clear:both; 101 | width:125px; 102 | height:31px; 103 | background:#666666 url(../img/button.png) no-repeat; 104 | text-align:center; 105 | line-height:31px; 106 | color:#FFFFFF; 107 | font-size:11px; 108 | font-weight:bold; 109 | } 110 | 111 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/handheld.css: -------------------------------------------------------------------------------- 1 | 2 | /* mobile styles */ 3 | @media handheld { 4 | 5 | html, body { 6 | font: 12px/15px sans-serif; 7 | background: #fff; 8 | padding: 3px; 9 | color: #000; 10 | margin: 0; 11 | } 12 | #sidebar, #footer { 13 | display: none; 14 | } 15 | h1, h2, h3, h4, h5, h6 { 16 | font-weight: normal; 17 | } 18 | #content img { 19 | max-width: 250px; 20 | } 21 | .center { 22 | width: 100%; !important; 23 | text-align: center; 24 | } 25 | a:link, a:visited { 26 | text-decoration: underline; 27 | color: #0000CC; 28 | } 29 | a:hover, a:active { 30 | text-decoration: underline; 31 | color: #660066; 32 | } 33 | 34 | } 35 | /* iPhone-specific styles */ 36 | @media only screen and (max-device-width: 480px) { 37 | 38 | html { 39 | -webkit-text-size-adjust: none; 40 | } 41 | 42 | } 43 | .myform{ 44 | margin:0 auto; 45 | padding:14px; 46 | } 47 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/iphone.css: -------------------------------------------------------------------------------- 1 | /* 2 | iPhoneUI.css 3 | 4 | Base styles for iPhone Web applications, based on Apple's 5 | recommended user interface styles. 6 | 7 | http://developer.apple.com/iphone/designingcontent.html 8 | */ 9 | 10 | body { 11 | font-family: Helvetica, Arial, sans-serif; 12 | margin: 0; 13 | padding: 0; 14 | } 15 | 16 | .edgeToEdge { 17 | background-color: #fff; 18 | border-spacing: 0; 19 | border-width: 0; 20 | font-size: 20px; 21 | font-weight: bold; 22 | margin: 0; 23 | padding: 0; 24 | } 25 | 26 | .edgeToEdge.formButtons { 27 | margin: 0; 28 | padding: 10px; 29 | } 30 | 31 | .edgeToEdge .formList { 32 | font-weight: normal; 33 | } 34 | 35 | .edgeToEdge.formFields textarea, 36 | .roundedRect.formFields textarea, 37 | .roundedRect .formFields textarea { 38 | clear: left; 39 | display: block; 40 | width: 296px; 41 | } 42 | 43 | dl.edgeToEdge.formFields dd, 44 | dl.roundedRect.formFields dd, 45 | .roundedRect .formFields dd { 46 | border-bottom: 1px solid rgb(217,217,217); 47 | padding: 10px; 48 | margin: 0; 49 | text-align: right; 50 | } 51 | 52 | dl.edgeToEdge.formFields dd.last, 53 | dl.roundedRect.formFields dd.last, 54 | .roundedRect .formFields dd.last { 55 | border-bottom-width: 0; 56 | } 57 | 58 | dl.edgeToEdge.formFields dt, 59 | dl.roundedRect.formFields dt, 60 | .roundedRect .formFields dt { 61 | clear: left; 62 | float: left; 63 | padding: 10px 10px 0 10px; 64 | margin: 0; 65 | } 66 | 67 | p.edgeToEdgeLast { 68 | border-bottom-width: 0; 69 | } 70 | 71 | form { 72 | margin: 0; 73 | } 74 | 75 | .formButtons { 76 | text-align: right; 77 | } 78 | 79 | .formList { 80 | list-style-type: none; 81 | margin: 0 0 -.33em 0; 82 | padding: 0; 83 | } 84 | 85 | .formList li { 86 | margin-bottom: .33em; 87 | } 88 | 89 | .formResults { 90 | background-color: #fff; 91 | -webkit-border-radius: 8px; 92 | color: #900; 93 | font: normal normal bold 17px/normal Helvetica, Arial, sans-serif; 94 | margin: 1em 10px; 95 | padding: 10px; 96 | text-align: center; 97 | } 98 | 99 | .iphone-preview-landscape, 100 | .iphone-preview-portrait { 101 | background-color: #A3A3A3; 102 | border: 1px solid #000; 103 | margin: 1em auto; 104 | min-height: 320px; 105 | width: 356px; 106 | } 107 | 108 | .iphone-preview-portrait { 109 | min-height: 356px; 110 | width: 320px; 111 | } 112 | 113 | .roundedRect { 114 | background-color: #fff; 115 | border-width: 0; 116 | font-family: Helvetica, Arial, sans-serif; 117 | font-size: 17px; 118 | font-weight: bold; 119 | margin: 10px; 120 | -webkit-border-radius: 8px 8px; 121 | } 122 | 123 | body.roundedRect, 124 | body.roundedRect .iphone-preview-landscape { 125 | background-color: #C5CCD3; 126 | } 127 | 128 | body.roundedRect { 129 | font: normal normal bold 17px/normal Helvetica, Arial, sans-serif; 130 | } 131 | 132 | div.roundedRect { 133 | margin: .6em 10px 1em 10px; 134 | padding: 1px 10px; 135 | } 136 | 137 | p.roundedRect { 138 | padding: 10px; 139 | } 140 | 141 | .roundedRectHead, 142 | .roundedRect legend { 143 | color: rgb(76,86,108); 144 | font: normal normal bold 17px/normal Helvetica, Arial, sans-serif; 145 | margin: 0; 146 | } 147 | 148 | .roundedRectIntHead { 149 | font: normal normal normal 21px/normal Helvetica, Arial, sans-serif; 150 | margin: 1em 0 -.75em 0; 151 | } 152 | 153 | fieldset.roundedRect { 154 | margin: 2em 10px 1em 10px; 155 | padding: 0 0 1px 0; 156 | } 157 | 158 | fieldset.roundedRect p { 159 | margin: 1em 10px; 160 | } 161 | 162 | .roundedRect legend { 163 | padding-left: 10px; 164 | position: relative; 165 | top: -.8em; 166 | } 167 | 168 | .roundedRectHead { 169 | margin: 1em 20px -.5em 20px; 170 | } 171 | 172 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/web.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; 3 | font-size:12px; 4 | margin:0px; 5 | } 6 | p, h1, form, button{border:0; margin:0; padding:0; 7 | } 8 | .spacer{clear:both; height:1px;} 9 | /* ----------- My Form ----------- */ 10 | .myform{ 11 | margin:0 auto; 12 | padding:14px; 13 | } 14 | 15 | .configform 16 | { 17 | 18 | } 19 | 20 | .config 21 | { 22 | font-size:8px; 23 | } 24 | 25 | .configform{ 26 | margin:0 auto; 27 | padding:14px; 28 | } 29 | 30 | /* ----------- basic ----------- */ 31 | #basic{ 32 | border:solid 2px #DEDEDE; 33 | } 34 | #basic h1 { 35 | font-size:14px; 36 | font-weight:bold; 37 | margin-bottom:8px; 38 | } 39 | #basic p{ 40 | font-size:11px; 41 | color:#666666; 42 | margin-bottom:20px; 43 | border-bottom:solid 1px #dedede; 44 | padding-bottom:10px; 45 | } 46 | #basic label{ 47 | display:block; 48 | font-weight:bold; 49 | 50 | width:140px; 51 | 52 | } 53 | #basic .small{ 54 | color:#666666; 55 | display:block; 56 | font-size:11px; 57 | font-weight:normal; 58 | 59 | } 60 | #basic input{ 61 | 62 | width:200px; 63 | margin:2px 0 30px 10px; 64 | } 65 | #basic button{ 66 | clear:both; 67 | margin-left:150px; 68 | background:#888888; 69 | color:#FFFFFF; 70 | border:solid 1px #666666; 71 | font-size:11px; 72 | font-weight:bold; 73 | padding:4px 6px; 74 | } 75 | 76 | 77 | /* ----------- stylized ----------- */ 78 | #stylized{ 79 | border:solid 2px #b7ddf2; 80 | background:#ebf4fb; 81 | } 82 | #stylized h1 { 83 | font-size:14px; 84 | font-weight:bold; 85 | margin-bottom:8px; 86 | } 87 | #stylized p{ 88 | font-size:11px; 89 | color:#666666; 90 | margin-bottom:5px; 91 | border-bottom:solid 1px #b7ddf2; 92 | padding-bottom:10px; 93 | } 94 | #stylized label{ 95 | display:block; 96 | font-weight:bold; 97 | 98 | 99 | } 100 | #stylized .small{ 101 | color:#666666; 102 | display:block; 103 | font-size:11px; 104 | font-weight:normal; 105 | 106 | } 107 | #stylized input, #stylized select, #stylized textarea{ 108 | 109 | font-size:12px; 110 | padding:4px 2px; 111 | border:solid 1px #aacfe4; 112 | width:200px; 113 | margin:2px 0 5px 0px; 114 | } 115 | #stylized button{ 116 | clear:both; 117 | width:125px; 118 | height:31px; 119 | background:#666666 url(../img/button.png) no-repeat; 120 | text-align:center; 121 | line-height:31px; 122 | color:#FFFFFF; 123 | font-size:11px; 124 | font-weight:bold; 125 | } 126 | 127 | .msg-out{ 128 | clear:both; 129 | height:31px; 130 | background:#666666; 131 | line-height:31px; 132 | color:#FFFFFF; 133 | font-size:11px; 134 | font-weight:bold; 135 | padding:5px; 136 | } 137 | 138 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/web.css~: -------------------------------------------------------------------------------- 1 | body{ 2 | font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; 3 | font-size:12px; 4 | margin:0px; 5 | } 6 | p, h1, form, button{border:0; margin:0; padding:0; 7 | } 8 | .spacer{clear:both; height:1px;} 9 | /* ----------- My Form ----------- */ 10 | .myform{ 11 | margin:0 auto; 12 | padding:14px; 13 | } 14 | 15 | .configform 16 | { 17 | display:none; 18 | } 19 | 20 | .config 21 | { 22 | font-size:8px; 23 | } 24 | 25 | .configform{ 26 | margin:0 auto; 27 | padding:14px; 28 | } 29 | 30 | /* ----------- basic ----------- */ 31 | #basic{ 32 | border:solid 2px #DEDEDE; 33 | } 34 | #basic h1 { 35 | font-size:14px; 36 | font-weight:bold; 37 | margin-bottom:8px; 38 | } 39 | #basic p{ 40 | font-size:11px; 41 | color:#666666; 42 | margin-bottom:20px; 43 | border-bottom:solid 1px #dedede; 44 | padding-bottom:10px; 45 | } 46 | #basic label{ 47 | display:block; 48 | font-weight:bold; 49 | 50 | width:140px; 51 | 52 | } 53 | #basic .small{ 54 | color:#666666; 55 | display:block; 56 | font-size:11px; 57 | font-weight:normal; 58 | 59 | } 60 | #basic input{ 61 | 62 | width:200px; 63 | margin:2px 0 30px 10px; 64 | } 65 | #basic button{ 66 | clear:both; 67 | margin-left:150px; 68 | background:#888888; 69 | color:#FFFFFF; 70 | border:solid 1px #666666; 71 | font-size:11px; 72 | font-weight:bold; 73 | padding:4px 6px; 74 | } 75 | 76 | 77 | /* ----------- stylized ----------- */ 78 | #stylized{ 79 | border:solid 2px #b7ddf2; 80 | background:#ebf4fb; 81 | } 82 | #stylized h1 { 83 | font-size:14px; 84 | font-weight:bold; 85 | margin-bottom:8px; 86 | } 87 | #stylized p{ 88 | font-size:11px; 89 | color:#666666; 90 | margin-bottom:5px; 91 | border-bottom:solid 1px #b7ddf2; 92 | padding-bottom:10px; 93 | } 94 | #stylized label{ 95 | display:block; 96 | font-weight:bold; 97 | 98 | 99 | } 100 | #stylized .small{ 101 | color:#666666; 102 | display:block; 103 | font-size:11px; 104 | font-weight:normal; 105 | 106 | } 107 | #stylized input, #stylized select, #stylized textarea{ 108 | 109 | font-size:12px; 110 | padding:4px 2px; 111 | border:solid 1px #aacfe4; 112 | width:200px; 113 | margin:2px 0 5px 0px; 114 | } 115 | #stylized button{ 116 | clear:both; 117 | width:125px; 118 | height:31px; 119 | background:#666666 url(../img/button.png) no-repeat; 120 | text-align:center; 121 | line-height:31px; 122 | color:#FFFFFF; 123 | font-size:11px; 124 | font-weight:bold; 125 | } 126 | 127 | .msg-out{ 128 | clear:both; 129 | height:31px; 130 | background:#666666; 131 | line-height:31px; 132 | color:#FFFFFF; 133 | font-size:11px; 134 | font-weight:bold; 135 | padding:5px; 136 | } 137 | 138 | -------------------------------------------------------------------------------- /joomla_1.5/samples/css/web_bac.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif; 3 | font-size:12px; 4 | } 5 | p, h1, form, button{border:0; margin:0; padding:0; 6 | } 7 | .spacer{clear:both; height:1px;} 8 | /* ----------- My Form ----------- */ 9 | .myform{ 10 | margin:0 auto; 11 | width:400px; 12 | padding:14px; 13 | } 14 | /* ----------- basic ----------- */ 15 | #basic{ 16 | border:solid 2px #DEDEDE; 17 | } 18 | #basic h1 { 19 | font-size:14px; 20 | font-weight:bold; 21 | margin-bottom:8px; 22 | } 23 | #basic p{ 24 | font-size:11px; 25 | color:#666666; 26 | margin-bottom:20px; 27 | border-bottom:solid 1px #dedede; 28 | padding-bottom:10px; 29 | } 30 | #basic label{ 31 | display:block; 32 | font-weight:bold; 33 | text-align:right; 34 | width:140px; 35 | float:left; 36 | } 37 | #basic .small{ 38 | color:#666666; 39 | display:block; 40 | font-size:11px; 41 | font-weight:normal; 42 | text-align:right; 43 | width:140px; 44 | } 45 | #basic input{ 46 | float:left; 47 | width:200px; 48 | margin:2px 0 30px 10px; 49 | } 50 | #basic button{ 51 | clear:both; 52 | margin-left:150px; 53 | background:#888888; 54 | color:#FFFFFF; 55 | border:solid 1px #666666; 56 | font-size:11px; 57 | font-weight:bold; 58 | padding:4px 6px; 59 | } 60 | 61 | 62 | /* ----------- stylized ----------- */ 63 | #stylized{ 64 | border:solid 2px #b7ddf2; 65 | background:#ebf4fb; 66 | } 67 | #stylized h1 { 68 | font-size:14px; 69 | font-weight:bold; 70 | margin-bottom:8px; 71 | } 72 | #stylized p{ 73 | font-size:11px; 74 | color:#666666; 75 | margin-bottom:20px; 76 | border-bottom:solid 1px #b7ddf2; 77 | padding-bottom:10px; 78 | } 79 | #stylized label{ 80 | display:block; 81 | font-weight:bold; 82 | text-align:right; 83 | width:140px; 84 | float:left; 85 | } 86 | #stylized .small{ 87 | color:#666666; 88 | display:block; 89 | font-size:11px; 90 | font-weight:normal; 91 | text-align:right; 92 | width:140px; 93 | } 94 | #stylized input, #stylized select, #stylized textarea{ 95 | float:left; 96 | font-size:12px; 97 | padding:4px 2px; 98 | border:solid 1px #aacfe4; 99 | width:200px; 100 | margin:2px 0 20px 10px; 101 | } 102 | #stylized button{ 103 | clear:both; 104 | margin-left:150px; 105 | width:125px; 106 | height:31px; 107 | background:#666666 url(img/button.png) no-repeat; 108 | text-align:center; 109 | line-height:31px; 110 | color:#FFFFFF; 111 | font-size:11px; 112 | font-weight:bold; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /joomla_1.5/samples/functions.php: -------------------------------------------------------------------------------- 1 | '; 6 | $op .= print_r($array, true); 7 | $op .= ''; 8 | 9 | if ($print) 10 | echo $op; 11 | else 12 | return $op; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /joomla_1.5/samples/group_create.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | REST API for Joomla 6 | 7 | 8 | 9 | 10 | 11 | 12 | 34 | 35 |
36 |
37 |

Create Group

38 |

New group info

39 |
40 | 43 | 44 | 45 | 48 | 49 | 50 | 53 | 54 | 55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 |
65 | 66 |
67 |
68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /joomla_1.5/samples/group_create.php: -------------------------------------------------------------------------------- 1 | createRequest($url,"POST",$inputs); 25 | $rest->sendRequest(); 26 | $output = $rest->getResponse(); 27 | 28 | echo $output; 29 | prx($output); 30 | 31 | -------------------------------------------------------------------------------- /joomla_1.5/samples/img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techjoomla/Joomla-REST-API/33f59fa5f8afb8b5761de545e9eaf5b8c8800fc9/joomla_1.5/samples/img/.DS_Store -------------------------------------------------------------------------------- /joomla_1.5/samples/img/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techjoomla/Joomla-REST-API/33f59fa5f8afb8b5761de545e9eaf5b8c8800fc9/joomla_1.5/samples/img/button.png -------------------------------------------------------------------------------- /joomla_1.5/samples/user_crud.php: -------------------------------------------------------------------------------- 1 | createRequest($url,"POST",$inputs); 22 | $rest->sendRequest(); 23 | $output = $rest->getResponse(); 24 | 25 | echo '

Create

'; 26 | echo $output; 27 | $op = json_decode($output); 28 | prx($op); 29 | // End create 30 | 31 | // Read 32 | $url = "http://example.com/rest/user_list.json?id=" . $op->id; 33 | $rest= new RESTclient(); 34 | $rest->createRequest($url,"GET",array()); 35 | $rest->sendRequest(); 36 | $output = $rest->getResponse(); 37 | 38 | echo '

Read

'; 39 | echo $output; 40 | $op = json_decode($output); 41 | prx($op); 42 | // End Read 43 | 44 | // update 45 | $inputs['userid'] = $op->records[0]->id; 46 | $inputs['jspt'] = 1; 47 | $inputs["name"] = "Ashwin Date"; 48 | 49 | $url = "http://example.com/rest/user_update.json"; 50 | $rest= new RESTclient(); 51 | $rest->createRequest($url,"POST",$inputs); 52 | $rest->sendRequest(); 53 | $output = $rest->getResponse(); 54 | 55 | echo '

Update

'; 56 | echo $output; 57 | $op = json_decode($output); 58 | prx($op); 59 | // End update 60 | 61 | // Read 62 | $url = "http://example.com/rest/user_list.json?id=" . $op->id; 63 | $rest= new RESTclient(); 64 | $rest->createRequest($url,"GET",array()); 65 | $rest->sendRequest(); 66 | $output = $rest->getResponse(); 67 | 68 | echo '

Read

'; 69 | echo $output; 70 | $op = json_decode($output); 71 | prx($op); 72 | // End Read 73 | 74 | // Delete 75 | $inputs['id'] = $op->records[0]->id; 76 | $url = "http://example.com/rest/user_delete.json"; 77 | $rest= new RESTclient(); 78 | $rest->createRequest($url,"POST",$inputs); 79 | $rest->sendRequest(); 80 | $output = $rest->getResponse(); 81 | 82 | echo '

Delete

'; 83 | echo $output; 84 | $op = json_decode($output); 85 | prx($op); 86 | // End Delete 87 | -------------------------------------------------------------------------------- /joomla_1.5/server/.htaccess: -------------------------------------------------------------------------------- 1 | #.htaccess code 2 | RewriteEngine On 3 | RewriteRule ^(.*)$ index.php [L] 4 | 5 | -------------------------------------------------------------------------------- /joomla_1.5/server/classes.php: -------------------------------------------------------------------------------- 1 | <$rootNodeName />"); 15 | } 16 | 17 | // loop through the data passed in. 18 | foreach($data as $key => $value) 19 | { 20 | // no numeric keys in our xml please! 21 | if (is_numeric($key)) 22 | { 23 | // make string key... 24 | $key = "child_". (string) $key; 25 | } 26 | 27 | // replace anything not alpha numeric 28 | $key = preg_replace('/[^a-z]/i', '', $key); 29 | 30 | // if there is another array found recrusively call this function 31 | if (is_array($value)) 32 | { 33 | $node = $xml->addChild($key); 34 | // recrusive call. 35 | ArrayToXML::toXml($value, $rootNodeName, $node); 36 | } 37 | else 38 | { 39 | // add single node. 40 | $value = htmlentities($value); 41 | $xml->addChild($key,$value); 42 | } 43 | 44 | } 45 | // pass back as string. or simple xml object if you want! 46 | return $xml->asXML(); 47 | } 48 | } 49 | 50 | class JoomlaRest { 51 | 52 | function getList($arr) { 53 | $html = ''; 54 | foreach ($arr as $method) { 55 | $html .= '' . "\n"; 56 | 57 | $html .= ""; 58 | 59 | $html .= '' . "\n"; 60 | } 61 | 62 | $html .= '
{$method->element}
{$method->name}
'; 63 | 64 | return $html; 65 | } 66 | 67 | function getInfo($method) { 68 | 69 | $html = ''; 70 | $html .= 'API Information' . "\n"; 71 | $html .= '' . "\n"; 72 | $html .= '' . "\n"; 73 | 74 | $html .= ''; 75 | foreach ($method as $vars) { 76 | $html .= '' . "\n"; 77 | 78 | if ($vars->required) { $vars->name = '' . $vars->name . '*'; } 79 | $html .= ""; 80 | 81 | $html .= '' . "\n"; 82 | } 83 | 84 | $html .= '
{$vars->name}
{$vars->desc}
'; 85 | 86 | return $html; 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /joomla_1.5/server/includes/application.php: -------------------------------------------------------------------------------- 1 | _encoding = "UTF-8"; 50 | 51 | //Set the root in the URI based on the application name 52 | JURI::root(null, str_replace('/'.$this->getName(), '', JURI::base(true))); 53 | 54 | } 55 | 56 | /** 57 | * Get the charset encoding 58 | * 59 | * @return string the charset encoding 60 | * @since 1.5 61 | */ 62 | function getEncoding() { 63 | return $this->_encoding; 64 | } 65 | 66 | /** 67 | * Set the charset encoding 68 | * 69 | * @var $encoding The encoding of the charset 70 | */ 71 | function setEncoding($encoding) { 72 | $this->_encoding = $encoding; 73 | } 74 | } 75 | ?> 76 | -------------------------------------------------------------------------------- /joomla_1.5/server/includes/custom_json.php: -------------------------------------------------------------------------------- 1 | $value) { 31 | $output .= '"'.$key.'":'; 32 | if(is_array($value)) $output .= self::encode($value); 33 | else $output .= self::_val($value); 34 | if($i !== $last) $output .= ','; 35 | ++$i; 36 | } 37 | $output .= '}'; 38 | 39 | } 40 | 41 | // return 42 | return $output; 43 | 44 | } 45 | 46 | /** 47 | * [INTERNAL] Format value 48 | * @param mixed $val the value 49 | * @return string 50 | */ 51 | private static function _val($val) 52 | { 53 | if(is_string($val)) return '"'.rawurlencode($val).'"'; 54 | elseif(is_int($val)) return sprintf('%d', $val); 55 | elseif(is_float($val)) return sprintf('%F', $val); 56 | elseif(is_bool($val)) return ($val ? 'true' : 'false'); 57 | else return 'null'; 58 | } 59 | 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /joomla_1.5/server/includes/defines.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /joomla_1.5/server/includes/framework.php: -------------------------------------------------------------------------------- 1 | error_reporting === 0) { 45 | error_reporting( 0 ); 46 | } else if (@$CONFIG->error_reporting > 0) { 47 | error_reporting( $CONFIG->error_reporting ); 48 | ini_set( 'display_errors', 1 ); 49 | } 50 | 51 | unset( $CONFIG ); 52 | 53 | /* 54 | * Joomla! framework loading 55 | */ 56 | 57 | // Include object abstract class 58 | require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php'); 59 | 60 | // Joomla! library imports 61 | jimport( 'joomla.environment.uri' ); 62 | jimport( 'joomla.user.user' ); 63 | jimport( 'joomla.event.event'); 64 | jimport( 'joomla.event.dispatcher'); 65 | jimport( 'joomla.plugin.helper' ); 66 | jimport( 'joomla.utilities.string' ); 67 | ?> -------------------------------------------------------------------------------- /joomla_1.5/server/includes/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /joomla_1.5/server/index.php: -------------------------------------------------------------------------------- 1 | login($credentials, $options); 52 | $user = JFactory::getUser(); 53 | 54 | // Unset access credos 55 | unset($req['auth_user'],$req['auth_pass']); 56 | 57 | // Run method only if login succeds and user is > Administrator 58 | if (($authenticated === true && $user->id) || $noauth) { 59 | 60 | // load all available remote calls 61 | JPluginHelper::importPlugin( 'restapi', $call ); 62 | 63 | if ($format == 'info') { 64 | $plugin = $mainframe->triggerEvent( 'onRestInfo', array($req) ); 65 | } else { 66 | $plugin = $mainframe->triggerEvent( 'onRestCall', array($req) ); 67 | } 68 | 69 | } else { 70 | $plugin[0] = 'Cannot login - Please provide correct auth_user and auth_password'; 71 | } 72 | 73 | // Generate response 74 | switch ($format) { 75 | 76 | case 'json': 77 | default: 78 | $document->setMimeEncoding('application/json'); 79 | $op = json_encode($plugin[0]); 80 | // $op = custom_json::encode($plugin[0]); 81 | break; 82 | 83 | case 'xml': 84 | $document->setMimeEncoding('application/xml'); 85 | $op = ArrayToXML::toXml($plugin[0]); 86 | break; 87 | 88 | case 'html': 89 | break; 90 | 91 | case 'info': 92 | $op = JoomlaRest::getInfo($plugin[0]); 93 | break; 94 | 95 | } 96 | 97 | // Logout 98 | $mainframe->logout(); 99 | 100 | // Deliver response to client 101 | echo $op; 102 | jexit(); 103 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_create/group_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group - Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group plugin 12 | 13 | group_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_discussion_create/group_discussion_create.php: -------------------------------------------------------------------------------- 1 | createnewgroupdiscussion( $data ); 38 | 39 | return $id; 40 | } 41 | 42 | function onRestInfo() { 43 | 44 | } 45 | 46 | function createnewgroupdiscussion( $data ) { 47 | 48 | require_once( JPATH_SITE .'/components/com_community/libraries/core.php'); 49 | CFactory::load( 'libraries' , 'apps' ); 50 | 51 | $error_messages = array(); 52 | $response = NULL; 53 | $validated = true; 54 | $db = &JFactory::getDBO(); 55 | $survey_filepath = JPATH_ROOT.DS.'configuration'.DS.'surveyfiles'.DS.$data['survey_filename']; 56 | 57 | if( "" == $data['creator'] || 0 == $data['creator']) { 58 | $validated = false; 59 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"Creator cannot be blank"); 60 | } 61 | 62 | if( "" == $data['groupid'] || 0 == $data['groupid']) { 63 | $validated = false; 64 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Groupid cannot be blank"); 65 | } 66 | if( $data['title'] == "" || 0 == strlen($data['title'])) 67 | { 68 | $validated = false; 69 | $error_messages[] = array("id"=>1,"fieldname"=>"title","message"=>"Title cannot be blank"); 70 | } 71 | 72 | if($data['message'] == "" || 0 == strlen($data['message'])) 73 | { 74 | $validated = false; 75 | $error_messages[] = array("id"=>1,"fieldname"=>"message","message"=>"Message cannot be blank"); 76 | } 77 | 78 | 79 | $inputFilter = CFactory::getInputFilter( true ); 80 | $validated = true; 81 | 82 | 83 | 84 | if( true == $validated ) { 85 | 86 | // Bind the data with the table first 87 | $discussion =& JTable::getInstance( 'Discussion' , 'CTable' ); 88 | $discussion->set( 'title', strip_tags( $data['title'] )); 89 | $discussion->set( 'message', $inputFilter->clean( $data['message'] )); 90 | $discussion->set( 'groupid', $data['groupid'] ); 91 | $discussion->set( 'creator', $data['creator'] ); 92 | $discussion->set( 'created', gmdate( 'Y-m-d H:i:s' )); 93 | $discussion->set( 'lastreplied',$discussion->created ); 94 | 95 | 96 | $isNew = is_null( $discussion->id ) || !$discussion->id ? true : false; 97 | 98 | $query = "SELECT id FROM #__users WHERE id =".$data['creator']; 99 | $db->setQuery($query); 100 | $creator = $db->LoadResult(); 101 | 102 | $query = "SELECT id FROM #__community_groups WHERE id =".$data['groupid']; 103 | $db->setQuery($query); 104 | $isgroup = $db->LoadResult(); 105 | 106 | if(!$creator){ 107 | 108 | $error_messages[] = array("id"=>1,"fieldname"=>"creator","message"=>"Invalid discussion creator id. Check 'creator' field in request"); 109 | } 110 | if(!$isgroup){ 111 | 112 | $error_messages[] = array("id"=>1,"fieldname"=>"groupid","message"=>"Invalid group id. Check 'groupid' field in request"); 113 | }else{ 114 | 115 | if(!file_exists($survey_filepath)) 116 | { 117 | $validated = false; 118 | $error_messages[] = array("id"=>1,"fieldname"=>"survey_filename","message"=>"Invalid Survey File Name"); 119 | 120 | } else { 121 | // Save the discussion. 122 | $discussion->store(); 123 | 124 | $survey = new stdClass; 125 | $survey->group_id = $data['groupid']; 126 | $survey->discussion_id = $discussion->id; 127 | $survey->status = 0; 128 | $survey->timestamp = date('Y-m-d H:i:s'); 129 | $survey->filename = $data['survey_filename']; 130 | $db->insertObject( '#__myhsclosure_survey', $survey,'discussion_id'); 131 | 132 | } 133 | 134 | } 135 | 136 | 137 | //add user points 138 | CFactory::load( 'libraries', 'userpoints' ); 139 | CUserPoints::assignPoint( 'group.discussion.create' ); 140 | if(!$creator) 141 | { 142 | 143 | }if(!$isgroup) 144 | { 145 | 146 | }else if($data['isqm']!='') 147 | { 148 | $db = &JFactory::getDBO(); 149 | $row = new stdClass; 150 | $row->id = NULL; 151 | $row->discussion_id = $discussion->id; 152 | $row->qm_flag = $data['isqm']; 153 | $db->insertObject( '#__myhs_qmflag', $row, 'id' ); 154 | } 155 | } 156 | 157 | if( true == isset( $error_messages ) && 0 < sizeof( $error_messages )) { 158 | $res= array(); 159 | foreach( $error_messages as $key => $error_message ) 160 | { 161 | $res[] = $error_message; 162 | 163 | } 164 | 165 | $response = array("id" => 0,'errors'=>$res); 166 | } else { 167 | $response = array('id' => $discussion->id); 168 | } 169 | 170 | return $response; 171 | 172 | } 173 | 174 | 175 | } 176 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_discussion_create/group_discussion_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create Group Discussion- Example 4 | Joomla! Project 5 | October 2010 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an create group discussion plugin 12 | 13 | group_discussion_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_discussion_list/group_discussion_list.php: -------------------------------------------------------------------------------- 1 | Quote($group_id); 67 | $flag = false; 68 | } 69 | 70 | if ($user_id) { 71 | $where[] = 'd.creator = ' . $db->Quote($user_id); 72 | $flag = false; 73 | } 74 | 75 | if ($username) { 76 | $where[] = "u.username LIKE '%".$username."%'"; 77 | $flag = false; 78 | } 79 | 80 | if($startdt && $enddt){ 81 | //$where[] = ' date(d.lastreplied) >= "'.$startdt. '" AND date(d.lastreplied) <= "'.$enddt.'"'; 82 | $where[] = ' d.lastreplied BETWEEN '.$db->quote($startdt).' AND '.$db->quote($enddt); 83 | $flag = false; 84 | } 85 | 86 | if($startdt) { 87 | $where[] = ' date(d.lastreplied) ='.$db->quote($startdt); 88 | $flag = false; 89 | } 90 | 91 | $where[]= " d.creator = u.id"; 92 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 93 | 94 | if(!$flag) 95 | { 96 | $qry = "SELECT d.id AS discussionid,d.groupid AS groupid,d.creator AS userid,d.title,d.message,d.lastreplied 97 | FROM #__community_groups_discuss As d, #__users AS u 98 | {$where} LIMIT {$start}, {$limit}"; 99 | $db->setQuery($qry); 100 | $discussrec = $db->loadAssocList(); 101 | $discusscount = count($discussrec); 102 | 103 | if($discusscount) { 104 | $discuss = array('size' => $discusscount,'records'=>$discussrec); 105 | }else{ 106 | $discuss = array('size' => 0); 107 | } 108 | 109 | }else{ 110 | $discuss=false; 111 | } 112 | 113 | if(!$discuss){ 114 | $discusserror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Discuss id is not available'); 115 | $discusserror[] = array("id"=>1,"fieldname"=>"groupid",'message'=>'Group id is not available'); 116 | $discusserror[] = array("id"=>1,"fieldname"=>"userid",'message'=>'Userid is not available'); 117 | $discusserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 118 | $discusserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 119 | $discusserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 120 | 121 | $discuss = array('size' => -1,'errors'=>$discusserror); 122 | } 123 | 124 | return $discuss; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_discussion_list/group_discussion_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group Discussion List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group discussion list plugin 12 | 13 | group_discussion_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_list/group_list.php: -------------------------------------------------------------------------------- 1 | = "'.$startdt. '" AND date(g.created) <= "'.$enddt.'"'; 76 | $where[] = ' g.created BETWEEN '.$db->quote($startdt).' AND '.$db->quote($enddt); 77 | $flag = false; 78 | } 79 | 80 | if($startdt) { 81 | $where[] = ' date(g.created) ='.$db->quote($startdt); 82 | $flag = false; 83 | } 84 | 85 | $where[]= " g.ownerid = u.id AND g.published = 1 "; 86 | $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); 87 | 88 | if(!$flag) 89 | { 90 | $qry = "SELECT g.id AS groupid,g.name AS groupname,g.description,g.email,g.website,g.created 91 | FROM #__community_groups As g, #__users AS u 92 | {$where} LIMIT {$start}, {$limit}"; 93 | $db->setQuery($qry); 94 | $grouprec = $db->loadAssocList(); 95 | $groupcount = count($grouprec); 96 | 97 | if($groupcount) { 98 | $grouplist = array('size' => $groupcount,'records'=>$grouprec); 99 | }else{ 100 | $grouplist = array('size' => 0); 101 | } 102 | 103 | }else{ 104 | $grouplist=false; 105 | } 106 | 107 | if(!$grouplist){ 108 | $grouplisterror[] = array("id"=>1,"fieldname"=>"id",'message'=>'Group id is not available'); 109 | $grouplisterror[] = array("id"=>1,"fieldname"=>"groupname",'message'=>'Group Name is not available'); 110 | $grouplisterror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 111 | $grouplisterror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 112 | $grouplisterror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 113 | 114 | $grouplist = array('size' => -1,'errors'=>$grouplisterror); 115 | } 116 | 117 | return $grouplist; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/group_list/group_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Group List - Example 4 | Joomla! Project 5 | Jan 2011 6 | Copyright (C) 2010 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an group list plugin 12 | 13 | group_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/user_create/user_create.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Authentication - Example 4 | Joomla! Project 5 | November 2005 6 | Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | admin@joomla.org 9 | www.joomla.org 10 | 1.5 11 | An example of an authentication plugin 12 | 13 | user_create.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/user_list/user_list.php: -------------------------------------------------------------------------------- 1 | $v) { 20 | $usersdata[$k]['jspt'] = XiptAPI::getUserProfiletype($v['id']); 21 | $usersdata[$k]['jsptname'] = XiptAPI::getUserProfiletype($v['id'], 'name'); 22 | } 23 | 24 | return $usersdata; 25 | }*/ 26 | 27 | function onRestCall ($data) { 28 | 29 | $db = JFactory::getDBO(); 30 | $start = JRequest::getInt('start', 0); 31 | $limit = JRequest::getInt('limit', 20); 32 | $id = JRequest::getInt('id'); 33 | $email = JRequest::getVar('email'); 34 | $name = JRequest::getVar('name'); 35 | $username = JRequest::getVar('username'); 36 | $startdt = JRequest::getVar('startdate'); 37 | $enddt = JRequest::getVar('enddate'); 38 | $modifieddt = JRequest::getVar('modifieddate'); 39 | $where = array(); 40 | $wheresql = ''; 41 | $flag = false; 42 | 43 | if($id == 0) 44 | { 45 | $flag = true; 46 | } 47 | 48 | if ($id!="" && $id!=0 && $id) { 49 | $where[] = 'id = ' . $id; 50 | $flag = false; 51 | } 52 | 53 | if ($email) { 54 | $where[] = 'email = ' . $db->Quote($email); 55 | $flag = false; 56 | } 57 | 58 | if ($name) { 59 | $where[] = "name LIKE '%".$name."%'"; 60 | $flag = false; 61 | } 62 | 63 | if ($username) { 64 | $where[] = "username LIKE '%" . $username . "%'"; 65 | $flag = false; 66 | } 67 | 68 | if($startdt && $enddt){ 69 | //$where[] = ' date(registerDate) >= "'.$startdt. '" AND date(registerDate) <= "'.$enddt.'"'; 70 | $where[] = ' registerDate BETWEEN '.$db->quote($startdt).' AND '.$db->quote($enddt); 71 | $flag = false; 72 | } 73 | 74 | if($startdt) { 75 | $where[] = ' date(registerDate) ='.$db->quote($startdt); 76 | $flag = false; 77 | } 78 | 79 | if($modifieddt){ 80 | $where[] = "date(lastvisitDate) LIKE '%".$modifieddt. "%'"; 81 | $flag = false; 82 | } 83 | 84 | if (count($where)) { 85 | $wheresql = 'WHERE block = 0 AND ' . implode(' AND ', $where); 86 | } 87 | 88 | if(!$flag){ 89 | $qry = "SELECT id, name, username, email, registerDate as registerdate, usertype 90 | FROM #__users {$wheresql} LIMIT {$start}, {$limit}"; 91 | 92 | $db->setQuery($qry); 93 | $usersrec = $db->loadAssocList(); 94 | $userscount = count($usersrec); 95 | 96 | if($userscount){ 97 | //$usersrec = $this->_extendUsers($usersrec); 98 | $users = array('size' => $userscount,'records'=>$usersrec); 99 | }else{ 100 | $users = array('size' => 0); 101 | } 102 | 103 | }else{ 104 | $users=false; 105 | } 106 | 107 | if(!$users){ 108 | $userserror[] = array("id"=>1,"fieldname"=>"name",'message'=>'name is not available'); 109 | $userserror[] = array("id"=>1,"fieldname"=>"id",'message'=>'id is not available'); 110 | $userserror[] = array("id"=>1,"fieldname"=>"email",'message'=>'Email id is not available'); 111 | $userserror[] = array("id"=>1,"fieldname"=>"username",'message'=>'Username is not available'); 112 | $userserror[] = array("id"=>1,"fieldname"=>"startdate",'message'=>'Start date is not valid'); 113 | $userserror[] = array("id"=>1,"fieldname"=>"enddate",'message'=>'End date is not valid'); 114 | $userserror[] = array("id"=>1,"fieldname"=>"modifieddate",'message'=>'Modified date is not valid'); 115 | $users = array('size' => -1,'errors'=>$userserror); 116 | } 117 | 118 | return $users; 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /joomla_1.6/plugins/user_list/user_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User List 4 | Ashwin Date 5 | 30/09/2010 6 | Copyright (C) 2010 Tekdi Web Solutions 7 | http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 8 | ashwin.date@tekdi.net 9 | www.tekdi.net 10 | 1.5 11 | Returns a list of users 12 | 13 | user_list.php 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /joomla_1.6/server/cache/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /joomla_1.6/server/classes.php: -------------------------------------------------------------------------------- 1 | <$rootNodeName />"); 15 | } 16 | 17 | // loop through the data passed in. 18 | foreach($data as $key => $value) 19 | { 20 | // no numeric keys in our xml please! 21 | if (is_numeric($key)) 22 | { 23 | // make string key... 24 | $key = "child_". (string) $key; 25 | } 26 | 27 | // replace anything not alpha numeric 28 | $key = preg_replace('/[^a-z]/i', '', $key); 29 | 30 | // if there is another array found recrusively call this function 31 | if (is_array($value)) 32 | { 33 | $node = $xml->addChild($key); 34 | // recrusive call. 35 | ArrayToXML::toXml($value, $rootNodeName, $node); 36 | } 37 | else 38 | { 39 | // add single node. 40 | $value = htmlentities($value); 41 | $xml->addChild($key,$value); 42 | } 43 | 44 | } 45 | // pass back as string. or simple xml object if you want! 46 | return $xml->asXML(); 47 | } 48 | } 49 | 50 | class JoomlaRest { 51 | 52 | function getList($arr) { 53 | $html = ''; 54 | foreach ($arr as $method) { 55 | $html .= '' . "\n"; 56 | 57 | $html .= ""; 58 | 59 | $html .= '' . "\n"; 60 | } 61 | 62 | $html .= '
{$method->element}
{$method->name}
'; 63 | 64 | return $html; 65 | } 66 | 67 | function getInfo($method) { 68 | 69 | $html = ''; 70 | $html .= 'API Information' . "\n"; 71 | $html .= '' . "\n"; 72 | $html .= '' . "\n"; 73 | 74 | $html .= ''; 75 | foreach ($method as $vars) { 76 | $html .= '' . "\n"; 77 | 78 | if ($vars->required) { $vars->name = '' . $vars->name . '*'; } 79 | $html .= ""; 80 | 81 | $html .= '' . "\n"; 82 | } 83 | 84 | $html .= '
{$vars->name}
{$vars->desc}
'; 85 | 86 | return $html; 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /joomla_1.6/server/includes/application.php: -------------------------------------------------------------------------------- 1 | _encoding = "UTF-8"; 50 | 51 | //Set the root in the URI based on the application name 52 | JURI::root(null, str_replace('/'.$this->getName(), '', JURI::base(true))); 53 | 54 | } 55 | 56 | /** 57 | * Get the charset encoding 58 | * 59 | * @return string the charset encoding 60 | * @since 1.5 61 | */ 62 | function getEncoding() { 63 | return $this->_encoding; 64 | } 65 | 66 | /** 67 | * Set the charset encoding 68 | * 69 | * @var $encoding The encoding of the charset 70 | */ 71 | function setEncoding($encoding) { 72 | $this->_encoding = $encoding; 73 | } 74 | } 75 | ?> 76 | -------------------------------------------------------------------------------- /joomla_1.6/server/includes/custom_json.php: -------------------------------------------------------------------------------- 1 | $value) { 31 | $output .= '"'.$key.'":'; 32 | if(is_array($value)) $output .= self::encode($value); 33 | else $output .= self::_val($value); 34 | if($i !== $last) $output .= ','; 35 | ++$i; 36 | } 37 | $output .= '}'; 38 | 39 | } 40 | 41 | // return 42 | return $output; 43 | 44 | } 45 | 46 | /** 47 | * [INTERNAL] Format value 48 | * @param mixed $val the value 49 | * @return string 50 | */ 51 | private static function _val($val) 52 | { 53 | if(is_string($val)) return '"'.rawurlencode($val).'"'; 54 | elseif(is_int($val)) return sprintf('%d', $val); 55 | elseif(is_float($val)) return sprintf('%F', $val); 56 | elseif(is_bool($val)) return ($val ? 'true' : 'false'); 57 | else return 'null'; 58 | } 59 | 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /joomla_1.6/server/includes/defines.php: -------------------------------------------------------------------------------- 1 | 32 | -------------------------------------------------------------------------------- /joomla_1.6/server/includes/framework.php: -------------------------------------------------------------------------------- 1 | error_reporting === 0) { 45 | error_reporting( 0 ); 46 | } else if (@$CONFIG->error_reporting > 0) { 47 | error_reporting( $CONFIG->error_reporting ); 48 | ini_set( 'display_errors', 1 ); 49 | } 50 | 51 | unset( $CONFIG ); 52 | 53 | /* 54 | * Joomla! framework loading 55 | */ 56 | 57 | // Include object abstract class 58 | require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php'); 59 | 60 | // Joomla! library imports 61 | jimport( 'joomla.environment.uri' ); 62 | jimport( 'joomla.user.user' ); 63 | jimport( 'joomla.event.event'); 64 | jimport( 'joomla.event.dispatcher'); 65 | jimport( 'joomla.plugin.helper' ); 66 | jimport( 'joomla.utilities.string' ); 67 | ?> 68 | -------------------------------------------------------------------------------- /joomla_1.6/server/includes/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /joomla_1.6/server/index.php: -------------------------------------------------------------------------------- 1 | login($credentials, $options); 52 | $user = JFactory::getUser(); 53 | 54 | // Unset access credos 55 | unset($req['auth_user'],$req['auth_pass']); 56 | 57 | // Run method only if login succeds and user is > Administrator 58 | if (($authenticated === true && $user->id) || $noauth) { 59 | 60 | // load all available remote calls 61 | JPluginHelper::importPlugin( 'restapi', $call ); 62 | 63 | if ($format == 'info') { 64 | $plugin = $mainframe->triggerEvent( 'onRestInfo', array($req) ); 65 | } else { 66 | $plugin = $mainframe->triggerEvent( 'onRestCall', array($req) ); 67 | } 68 | 69 | } else { 70 | $plugin[0] = 'Cannot login - Please provide correct auth_user and auth_password'; 71 | } 72 | 73 | // Generate response 74 | switch ($format) { 75 | 76 | case 'json': 77 | default: 78 | $document->setMimeEncoding('application/json'); 79 | $op = json_encode($plugin[0]); 80 | // $op = custom_json::encode($plugin[0]); 81 | break; 82 | 83 | case 'xml': 84 | $document->setMimeEncoding('application/xml'); 85 | $op = ArrayToXML::toXml($plugin[0]); 86 | break; 87 | 88 | case 'html': 89 | break; 90 | 91 | case 'info': 92 | $op = JoomlaRest::getInfo($plugin[0]); 93 | break; 94 | 95 | } 96 | 97 | // Logout 98 | $mainframe->logout(); 99 | 100 | 101 | /* **** Added By - Deepak 102 | * LOGLEVEL 0 - No logs save 103 | * 1 - Save only date, Method, IP 104 | * 2 - Save All. 105 | */ 106 | 107 | if(LOGLEVEL != 0) 108 | { 109 | 110 | if(LOGLEVEL == 2) 111 | { 112 | ApiHelperLogs::simpleLog($url['path'] . " request: " . JArrayHelper::toString($req)); 113 | ApiHelperLogs::simpleLog("Response: ". $op); 114 | } else if(LOGLEVEL == 1) { 115 | ApiHelperLogs::simpleLog($url['path'] . " request: " . JArrayHelper::toString($req)); 116 | } 117 | } 118 | 119 | 120 | 121 | // Deliver response to client 122 | echo $op; 123 | jexit(); 124 | 125 | 126 | class ApiHelperLogs 127 | { 128 | /** 129 | * Simple log 130 | * @param string $comment The comment to log 131 | * @param int $userId An optional user ID 132 | */ 133 | function simpleLog($comment, $level=1) 134 | { 135 | // Include the library dependancies 136 | jimport('joomla.error.log'); 137 | $my = JFactory::getUser(); 138 | $options = array('format' => "{DATE} - {TIME} - {IP} - {COMMENT}"); 139 | // Create the instance of the log file in case we use it later 140 | $log = &JLog::getInstance('restapi.log'); 141 | $log->addEntry(array('comment' => $comment, 'ip' => $_SERVER['REMOTE_ADDR'])); 142 | } 143 | } 144 | --------------------------------------------------------------------------------